I'm looking for a keyboard shortcut to close a window of an app, skipping the "Would you like to save" pester dialog, while leaving the app, itself, and other windows, still open.

If there's no way to do that, is there a keyboard shortcut for hitting a certain button in a window/dialog? In Windows, this would typically be ALT+[first letter of the button text].

  • 1
    I don't know about force-closing a window, but on Mac the pop-up dialog keyboard shortcuts are the same as Windows', only using Command instead of Alt. Also, when a dialog option is "destructive of a file" (e.g., "Delete," "Don't Save"), the key combination is Command-Delete.
    – aaplmath
    Commented Jul 6, 2017 at 18:08
  • Thanks! Command-Delete is the keyboard shortcut I was looking for (for the second part of my question). You should post that as an answer, rather than as a comment (it deserves an upvote).
    – Troy
    Commented Jul 6, 2017 at 18:22

1 Answer 1


To press a button in a dialog using a keyboard shortcut, press Command, followed by the first letter of the action you wish to trigger. The exception to this rule is if the action you wish to activate will delete a file or changes thereto, in which case the shortcut is Command-delete.

To force-close a window, you'd need to automate the correct series of key presses using AppleScript or something similar. The first key combination would likely be Command-W (though not even this is entirely universal). However, the dialog shortcuts vary by application—older versions of Microsoft Word don't comply with the Command-delete behavior (they use Command-D), while Automator's save sheets can often only be closed through mouse input. You would have to tailor this behavior to the specific applications in which you're interested. Such an AppleScript might look something like this (though be warned, triggering Command-delete without knowing the context is an easy way to accidentally delete files and large swathes of text):

tell application "System Events"
    keystroke "w" using {command down} -- Command-W
    delay 0.5 -- Wait for the dialog to appear
    key code 51 using {command down} -- Command-delete
end tell

To tie an AppleScript to a keyboard shortcut:

  • Open Automator (Applications > Utilities > Automator) and create a new Service (optionally, configure it just to run in the applications you want).
  • Add a "Run AppleScript" block in which you write your AppleScript.
  • Open System Preferences > Keyboard > Shortcuts.
  • Create a new shortcut, where the "Menu Title" is the title you gave your Service (again, you can tie this shortcut just to the applications to which your Service applies). The keyboard shortcut you enter here is the one you can use to trigger your "force close" behavior.

You could create multiple services, each one with the same keyboard shortcut but in different applications, corresponding to the unique behavior of each.

  • So MacOS has no equivalent to xkill because it thinks it's so perfect and when you find out that it's not perfect then things are so much more difficult or even impossible because.... "reasons". Okay I'll add it to my list.
    – LiveWireBT
    Commented Feb 26, 2023 at 23:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .