private static void LogMessageAndExit(Exception ex) { // Since we can't prevent the app from terminating, log this to the event log. Logging.Fatal(ErrorMsg, ex); if (_app != null) { _app.RemoveLockFile(); } Environment.Exit(1); }