You can use the MapInfoProExiting event to replicate the behavior you need for your application. This event is raised before MapInfo's own end handler is called and therefore you can execute your code in the handler of this event.I have attached a sample mapbasic code where you can see how to implement the MapInfoProExiting event. Search for MapInfoProExiting in the code.ThanksAnshul
I have attached the file again. This event is not part of standard MapBasic, it was introduced in 64 bit MapInfo Pro as part of extensibility framework.
You can check its documentation in Extensibility reference.Thanks
Function RBNEventSubscribe( ByVal nEventType As IntegerRBNEventSubscribe( ByVal nEventType As Integer , ByVal sMBXHandler As String )