Informs all message pumps that they must terminate, and then closes all application windows after the messages have been processed.
The Application.Exit method stops all running message loops on all threads and closes all windows of the application. This method does not necessarily force the application to exit. The Application.Exit method is typically called from within a message loop, and forces Application.Run to return. To exit a message loop for the current thread only, call Application.ExitThread.
Application.Exit raises the following events and performs the associated conditional actions:
A Form.FormClosing event is raised for every form represented by the Application.OpenForms property. This event can be canceled by setting the System.ComponentModel.CancelEventArgs.Cancel property of their System.Windows.Forms.FormClosingEventArgs parameter to true.
If one of more of the handlers cancels the event, then Application.Exit returns without further action. Otherwise, a Form.FormClosed event is raised for every open form, then all running message loops and forms are closed.
The Application.Exit method does not raise the Form.Closed and Form.Closing events, which are obsolete as of dnprdnlong.