private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (SettingsManager.getSettingBool("ShutdownAutohotkeyOnExit")) { AutoHotkeyManager.ShutdownAutohotkey(); } // create backup of settings on successful shutdown if (SettingsManager.getSettingBool("AutomaticSettingsBackup")) { SettingsManager.CreateBackup(); } if (fileWriter != null) { fileWriter.Close(); } ProcessManager.Stop(); }