private void Application_OnShutdown(object sender, EventArgs e) { TaskHandler.Shutdown(); ThreadHandler.Shutdown(); DbHandler.ShutDownDatabase(); CommandHelper.Destroy(); Application.Current.Dispatcher.Invoke((Action)(() => { OnCloseShellViewModel(); OnCloseLoginViewModel(); Application.Current.Shutdown(); })); }