diff --git a/Greenshot/Forms/MainForm.cs b/Greenshot/Forms/MainForm.cs index 00144b8f5..40760c152 100644 --- a/Greenshot/Forms/MainForm.cs +++ b/Greenshot/Forms/MainForm.cs @@ -328,20 +328,7 @@ namespace Greenshot { #region mainform events void MainFormFormClosing(object sender, FormClosingEventArgs e) { LOG.Info("Closing with reason: " + e.CloseReason); - - // Inform all registed plugins - PluginHelper.instance.Shutdown(); - - conf.Store(); - HotkeyHelper.UnregisterHotkeys((int)this.Handle); - SoundHelper.Deinitialize(); - if (applicationMutex != null) { - try { - applicationMutex.ReleaseMutex(); - } catch (Exception ex) { - LOG.Error("Error releasing Mutex!", ex); - } - } + exit(); } #endregion @@ -435,6 +422,7 @@ namespace Greenshot { } void Contextmenu_exitClick(object sender, EventArgs e) { + exit(); Application.Exit(); } @@ -536,5 +524,24 @@ namespace Greenshot { private void ImageWritten(object sender, ImageOutputEventArgs eventArgs) { lastImagePath = Path.GetDirectoryName(eventArgs.FullPath); } + + /// + /// Exit/cleanup + /// + private void exit() { + // Inform all registed plugins + PluginHelper.instance.Shutdown(); + + conf.Store(); + HotkeyHelper.UnregisterHotkeys((int)this.Handle); + SoundHelper.Deinitialize(); + if (applicationMutex != null) { + try { + applicationMutex.ReleaseMutex(); + } catch (Exception ex) { + LOG.Error("Error releasing Mutex!", ex); + } + } + } } }