private void MainForm_FormClosed(object sender, FormClosedEventArgs e) { notifyIcon.Visible = false; foreach (var id in hotKeyActions.Keys) { UnregisterHotKey(this.Handle, (Int32)id); } }