unload();
The unload event of the Form class occurs when a form is about to be removed from the screen. This event is triggered by a user action (closing the form using the Control-Menu icon) or by an unloadForm method.
The unload event and queryUnload events are not called if the form is unloaded before being displayed, the load event was never called, or if the delete method was used to delete the running instance of the form.
The unload event is always preceded by the queryUnload event, giving the opportunity to reject the requested closure. Use an unload event to specify actions to take place when the form is unloaded.
If a queryUnload method is aborted, queryUnload is not called for any other forms affected by the unload and all affected forms are unloaded without calling the unload event method. If an unload method is aborted, all other affected forms are unloaded without calling the unload method.
Unloading a form queues the window for deletion but if another window is deleted before the next idle point, previously queued deleted windows are re-evaluated for deletion. If the queued window or its children have no outstanding Windows message, there are no incomplete event methods for that window or its children, and the method that created the window has exited or the window was deleted, the physical window is deleted.
The unload event can be caused by using the unloadForm method or by the user taking an action; for example, selecting the Close command on the Control-Menu of a form, exiting from the application by using the End Task button on the Windows Task Manager, closing the MDI frame form for which the current form is a child form, or exiting the Windows environment while the application is running.
If the form is the last child of the default MDI frame (jade.exe-supplied), the MDI frame form is also closed. If the form is the last form for the application, the application is closed.