Exiting The Application (i.e. File > Exit menu item)
Application.Exit();
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:
this.Close();
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
Feel free to comment if you can add help to this page or point out issues and solutions you have found. I do not provide support on this site, if you need help with a problem head over to stack overflow.