Skip to Content
Sindre Sorhus
Back to Supercharge

Updated

How to Stop Command+W from Closing Windows by Accident on Mac

By Sindre Sorhus, who makes the Supercharge app

A wrong CommandW is worst in an app where the window is the work, like a web app that you added to the Dock from Safari.

With Supercharge

  1. Open Supercharge, and give it the access that it asks for in “Device Control and Data Access”.
  2. Open the Supercharge settings, and click “Tweaks”.
  3. In the “Apps & Windows” section, choose one of these in “Prevent accidental CommandW window closing by instead using”:
    • Press and hold CommandW.
    • Hold Command and press W twice.
    • Press ShiftCommandW.
  4. Click “No apps” below the menu, and choose the apps that it applies to. It does nothing until you choose an app.

Then a single press of CommandW does nothing in these apps, and the way you chose closes the window. In all other apps, CommandW works as before. To also stop CommandQ, see how to stop Command+Q from quitting apps by accident.

Get Supercharge

Elevate your Mac experience

$20, one-time purchase, plus tax where applicable

Requires
macOS 27 or later
Updated
November 2026
Gumroad rating
5.0/5 (293 ratings)

More about Supercharge

Without an app

macOS has no setting for this, but you can give the Close command of one app another shortcut, so CommandW does nothing in that app:

  1. Open “System Settings › Keyboard”, and click “Keyboard Shortcuts…”.
  2. Click “App Shortcuts”, and click the add button.
  3. Choose the app, and type the name of its command that closes the window, exactly like in the menu of the app.
  4. Click “Keyboard shortcut”, press the new shortcut, and click “Done”.

This is free, and it is enough for one or two apps. The name of the command is different between apps, and you must learn a new shortcut for each. With Supercharge, the keys stay the same, and only a longer press or a second press is needed.