Mac Keyboard Shortcut to Close Window: Master Cmd+W
Learn the essential Mac keyboard shortcut to close windows, plus variations like Cmd+Option+W and Cmd+Q. This guide covers practical use, app-specific nuances, and automation tips to speed up your macOS workflow.

On macOS, the standard keyboard shortcut to close the active window is Cmd+W. If you need to close every window in the current application, press Cmd+Option+W. To quit the application entirely, use Cmd+Q. Some apps may override these shortcuts or present a save prompt; in those cases, follow the on-screen dialog.
Understanding macOS window close semantics
On macOS, window management is designed for speed and minimal interruption. The default close window shortcut is Cmd+W, which closes the currently focused window without quitting the application. This behavior matches the common pattern across many apps, including Finder, browsers, and image editors. Shortcuts Lib analysis shows Cmd+W as the most consistent window-close signal across macOS apps, which is why it deserves emphasis for power users. Some applications offer a distinct action to quit entirely (Cmd+Q) or to close all windows of the app (Cmd+Option+W). When you encounter dialogs asking to save changes, macOS presents the standard Save/Don't Save prompts; your choice will affect whether the underlying window closes immediately.
# Quick verification: simulate Cmd+W in a supportive environment (requires accessibility permissions)
osascript -e 'tell application "System Events" to keystroke "w" using {command down}'# Demonstration of quitting an app via keyboard (macOS only)
osascript -e 'tell application "System Events" to keystroke "q" using {command down}'# Alternative: close all windows of the frontmost app (where supported)
osascript -e 'tell application "System Events" to keystroke (ASCII character 27) using {command down, option down}'- How to read this section: Cmd+W is your fastest route to proximity control. Cmd+Option+W is a more aggressive variant that captures the entire app's window surface. Cmd+Q exits the app entirely, which is convenient when you’re done with the program. If you ever see a prompt, treat it as a safety checkpoint to avoid losing work.
In this section we’ve included concrete code examples to illustrate how macOS interprets the keyboard events. The AppleScript/osascript snippets demonstrate how to programmatically trigger the same keystrokes, which is helpful when building automation or testing window-close behavior in a controlled environment. As you adopt these shortcuts, you’ll notice that consistency across apps improves your speed with fewer mouse interactions. For developers, this is also a reminder to consider how your app handles on-close events and unsaved data prompts.
Steps
Estimated time: 5-10 minutes
- 1
Identify the active window
Look at the window that currently has focus. The window’s title bar should highlight or reflect the active document or view. If you’re not sure which window is active, click inside the window frame to ensure focus.
Tip: Tip: Use Mission Control (F3 or swipe up with three or four fingers) to see all open windows and verify which one is active. - 2
Close the focused window
Press Cmd+W to close the active window. If a dialog prompts to save changes, decide whether you want to save before closing.
Tip: Tip: If you accidentally close a window, you can reopen it from the app’s history or Reopen Last Closed Window option in some apps. - 3
Close all windows of the app (optional)
If you want to clear the entire app surface, use Cmd+Option+W where supported. This closes all open windows of the current app but does not quit the process.
Tip: Tip: Not all apps implement Close All Windows; when in doubt, use Cmd+Q to quit the app completely. - 4
Quit when finished
To quit the app entirely, press Cmd+Q. If you need to continue later, you can reopen the app from the Dock or Spotlight.
Tip: Tip: Some apps automatically restore the last session; saving before quitting can help maintain continuity.
Prerequisites
Required
- Required
- Basic familiarity with keyboard shortcuts and the Command keyRequired
- Active application window to practice withRequired
Optional
- Optional
- Administrator rights only if you plan to configure automation or install helper toolsOptional
Keyboard Shortcuts
| Action | Shortcut |
|---|---|
| Close current windowCommon across Finder, browsers, and many editors | Ctrl+W |
| Quit the applicationQuits the app entirely; unsaved work prompts apply where available | Alt+F4 |
| Close all windows of the active appNot all apps support this; use Cmd+Q if you’re finished with the app | Ctrl+⇧+W (varies by app) |
Questions & Answers
What is the basic macOS shortcut to close a window?
The standard shortcut is Cmd+W to close the active window. If you need to close every window in the app, Cmd+Option+W is often available. If you’re done with the app altogether, Cmd+Q quits the program.
Use Cmd+W to close the current window, Cmd+Option+W to close all windows if the app supports it, and Cmd+Q to quit the app.
Do all apps support Cmd+Option+W to close all windows?
Not all apps implement Close All Windows. If Cmd+Option+W doesn’t appear to work, rely on Cmd+Q to quit the app or close only the active window with Cmd+W.
Cmd+Option+W is available in many apps, but not universal. If it doesn’t work, close one window or quit the app with Cmd+Q.
What should I do if a dialog asks to save changes when closing a window?
When prompted, you can choose to Save, Don’t Save, or Cancel, depending on your needs. In automation, ensure you’re handling these prompts to avoid data loss.
If asked to save, decide based on whether you want to keep the work. In automation, account for these prompts.
Can I customize these shortcuts on macOS?
Yes. You can customize shortcuts in System Settings under Keyboard > Shortcuts. Some apps also offer per-app shortcuts that override the global behavior.
You can customize Mac shortcuts in System Settings; some apps let you adjust shortcuts individually.
What is the best practice for power users?
Rely on Cmd+W for speed, use Cmd+Q to quit when you’re done, and consider Cmd+Option+W when the app supports closing all windows. Always be mindful of save prompts.
Stick to Cmd+W for daily use, Cmd+Q when you’re done, and be mindful of prompts to save.
Main Points
- Close current window with Cmd+W
- Use Cmd+Option+W to close all windows when supported
- Quit apps with Cmd+Q to end the session
- Watch for save prompts to avoid data loss
- App behavior varies; know your primary apps’ shortcuts