protected override void OnExit(ExitEventArgs e) { try { base.OnExit(e); // close any open services on exit ServiceProxy.Services.Dispose(); // dispose the ExceptionMessageHelper ExceptionMessageHelper.Helper.Dispose(); // save and dispose user settings UserSettings.Settings.Save(); UserSettings.Settings.Dispose(); // attempt to delete any files on the cleanup list if (_cleanup != null) { _cleanup.DeleteAll(); } Current.DispatcherUnhandledException -= Current_DispatcherUnhandledException; AppDomain.CurrentDomain.UnhandledException -= CurrentDomain_UnhandledException; } catch (Exception ex) { DiagnosticsHelper.LogException(DiagSeverity.ApplicationFatal, "App.OnExit Failed", ex); } finally { DiagnosticsHelper.LogAppExit(e.ApplicationExitCode); } }