Command + W on Mac: What It Does and How to Use It
In this article
Pressing Command + W on a Mac closes the frontmost window of the active app — not the whole app. The app keeps running in the Dock, and you can reopen a window with Command + N or by clicking the app icon. Nothing needs to be installed or enabled first; the shortcut is built into macOS.
What You'll Need
- A Mac running a current version of macOS (the shortcut has been standard for many years).
- At least one app open with a window in front of you.
- A keyboard with a working Command (⌘) key — on most Apple keyboards it sits next to the Space bar.
Step-by-Step
- Click once on the window you want to close so it becomes the active (frontmost) window. The active app's name appears in the menu bar at the top left.
- Press and hold the Command (⌘) key.
- While still holding Command, tap the W key once.
- Release both keys. The frontmost window closes. If the app has other windows open, they stay open; if it was the last window, the app usually remains running with no window.
- To bring the app back, click its icon in the Dock, or press Command + N to open a new window (in apps that support it).
- If a document has unsaved changes, a save dialog appears. Choose Save to keep your work, Don't Save to discard it, or Cancel to stop the window from closing.
Labels and dialog wording can differ slightly between macOS versions and apps, but the key combination is the same everywhere.
Common Mistakes
- Expecting the app to quit. Command + W closes a window; Command + Q quits the app entirely. If you want the app gone from the Dock, use Command + Q.
- Closing the wrong window. The shortcut always targets the frontmost window. Click the one you mean first.
- Assuming work is saved. Many apps prompt before closing an unsaved document, but some lightweight apps (notes-style or browser-based ones) may not. Save with Command + S before closing anything important.
- Confusing it with Command + Option + W. That combination closes all windows of the current app at once. Use it only when you mean to close everything.
- Using it in full-screen mode. In full-screen apps, Command + W may close the window and exit full screen, or the app may handle it differently. Press Control + Command + F to leave full screen first if the result is unexpected.
Tips
- Command + W works in most apps, including Finder, Safari, Mail, Pages, Numbers and third-party apps that follow Apple's interface conventions.
- In Safari, Command + W closes the current tab; if it is the last tab, the window closes. Command + Shift + W closes the whole Safari window.
- If you closed a tab by accident in Safari, reopen it with Command + Z or Command + Shift + T, depending on the version.
- To close every window of the current app in one go, use Command + Option + W.
- You can see which app is active by the name shown next to the Apple menu in the menu bar — a quick check before closing anything.
Troubleshooting
- Nothing happens when you press Command + W. Make sure the app window is actually active — click inside it first. Some apps, such as certain games or full-screen media players, intercept the shortcut and use their own close control.
- The whole app quits instead of just the window. You may have pressed Command + Q by mistake, or the app only supports a single window. Reopen it from the Dock.
- A dialog keeps appearing. That is the unsaved-changes prompt. Save your work, then close again.
- The shortcut does nothing in one specific app. Check the app's own menu bar: open the File menu and look for the Close command. The shortcut shown next to it is the one that app uses; if it shows something different, that app has remapped it.
- Keyboard behaving oddly. Test another shortcut such as Command + C. If several shortcuts fail, restart the Mac (Apple menu > Restart) before changing any settings.
- Still stuck. Sign out of your user account and back in (Apple menu > Log Out), which clears a stalled app without deleting files.
Frequently Asked Questions
Does Command + W quit the app?
No. It closes the frontmost window. The app stays open in the Dock until you quit it with Command + Q.
How do I close all windows of an app at once?
Press Command + Option + W. This closes every window of the active app but leaves the app running.
What is the difference between Command + W and Command + Q?
Command + W closes a window; Command + Q quits the entire application, closing all its windows.
Can I undo a window close?
In many apps, Command + Z or reopening from the app's File menu restores recently closed windows or tabs. Support varies by app.
Does Command + W work in Safari?
Yes. It closes the current tab, and if that is the last tab, the window closes. Command + Shift + W closes the entire Safari window.
Why does my Mac ask to save when I press Command + W?
The document has unsaved changes. Choose Save to keep them, Don't Save to discard, or Cancel to keep the window open.