Exiting The Application (i.e. File > Exit menu item)
Note that the Form..::.Closed and Form..::.Closing events are not raised when the Application..::.Exit method is called to exit your application. If you have validation code in either of these events that must be executed, you should call the Form..::.Close method for each open form individually before calling the Exit method.
Or just use this instead:
Debug Mode Only Compiler Check
#if DEBUG //Only do if we're in debug mode #endif #if !DEBUG //Only do if we're in release mode #endif #if (DEBUG && DEBUG_AUTO_LOG_IN_USER_ID) #endif