Maybe you have disabled events in your code? Hard to tell without seeing the code. Just guessing.
However you can still call the routine ino your code before closing the application.
Private Sub Workbook_BeforeClose(Cancel As Boolean)
MsgBox "test"
End Sub