Note :
The [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing.aspx"]FormClosing[/URL] event occurs just before a form is closed, either by the user, through the user interface (UI),
or programmatically, through calls to methods such as [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.close.aspx"]Close[/URL] in the [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.aspx"]Form[/URL] class, or [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.exit.aspx"]Exit[/URL] in the [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.application.aspx"]Application[/URL] class.
If a form has any child or owned forms, a [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosing.aspx"]FormClosing[/URL] event is also raised for each one. If any one of the forms cancels
the event, none of the forms are closed. Therefore the corresponding [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.form.formclosed.aspx"]FormClosed[/URL] events are not sent to any of the forms.
The FormClosingEventArgs class provides data for this event. Two important members are the [URL="http://msdn.microsoft.com/en-us/library/system.componentmodel.canceleventargs.cancel.aspx"]Cancel[/URL] and
[URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.closereason.aspx"]CloseReason[/URL] properties.
The event can be canceled by setting the [URL="http://msdn.microsoft.com/en-us/library/system.componentmodel.canceleventargs.cancel.aspx"]Cancel[/URL] property to true. The [URL="http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.closereason.aspx"]CloseReason[/URL] property provides a reason why the form is being closed.
So this is just a piece of cake , when the form is closing check for CloseReason argument. Then do ,your Job that application should take care off.
have a look at the MSdn documentation
http://msdn.microsoft.com/en-us/library/system.windows.forms.formclosingeventargs.aspx
Feed Me More +Reps