Culled from VFP Help:
Occurs before a form is unloaded, before the Destroy and Unload events. The form's Release Type property is set prior to the QueryUnload event being called, and indicates roughly what happened to trigger the event.
The QueryUnload event occurs when
RELEASE WINDOWS, or
QUIT is executed in code, or when the user double-clicks the window pop-up menu icon or chooses Close from the window pop-up menu on a form.
The QueryUnload event does not occur when a form's associated variable is released, if you issue the
RELEASE command on the form in code or invoke the form's Release method.
It's the place to double-check that the user really wants to close the form and to give her a chance to save her work before closing.
The Release Type property indicates how a form is being closed. It's set before QueryUnload triggers, so you can investigate in the QueryUnload method and take different actions based on the reason the form is closing.
You'll normally want to integrate QueryUnload for individual forms with an application's ON SHUTDOWN routine. That way, when a user closes your application by double-clicking in the main window, she'll get a chance to save her work in open windows.