I have a Windows Forms application that when the Main Window is closing, it displays a basic dialog box, confirming the action. If the user decides to cancel the application
you can use Application.SessionEnding Event to understand if the system is about to shutdown
http://msdn.microsoft.com/en-us/library/system.windows.application.sessionending.aspx