private void ShortcutControl_Unloaded(object sender, RoutedEventArgs e)
        {
            shortcutDialog.PrimaryButtonClick -= ShortcutDialog_PrimaryButtonClick;
            shortcutDialog.Opened             -= ShortcutDialog_Opened;
            shortcutDialog.Closing            -= ShortcutDialog_Closing;

            // Dispose the HotkeySettingsControlHook object to terminate the hook threads when the textbox is unloaded
            hook.Dispose();
        }
 private void HotkeyTextBox_Unloaded(object sender, RoutedEventArgs e)
 {
     // Dispose the HotkeySettingsControlHook object to terminate the hook threads when the textbox is unloaded
     hook.Dispose();
 }