The fastest way to close a window
Press Alt+F4 on Windows or Command+W on Mac. That closes the active window — the one you are currently using — when ready. No mouse needed, no menu hunting. On Windows, Alt+F4 works in almost every program. On Mac, Command+W closes the front window in most applications.
If you want to close the entire program instead of just one window, use Alt+F4 on Windows again (it closes the last window and quits the program), or Command+Q on Mac. The difference matters when you have multiple windows open in the same program — like two browser tabs or two document files.
These shortcuts work whether you are in a web browser, a word processor, a spreadsheet, or almost any other process. They are the same every time, which makes them worth memorizing if you spend hours at a keyboard.
Key Takeaways
- Alt+F4 on Windows and Command+W on Mac close the active window without touching the mouse.
- Alt+F4 on Windows or Command+Q on Mac will close the entire program and all its windows at once.
- These shortcuts work in nearly every program on your computer, from browsers to office software.
- Learning these two combinations saves you dozens of clicks per day if you regularly switch between windows.
When Alt+F4 or Command+W does not work
Some programs lock their windows or require you to save changes before closing. If you press Alt+F4 and nothing happens, the program is probably asking you to save unsaved work first. Look for a dialog box on screen — it may be behind other windows. Press Tab to move between buttons, then press Enter to select one.
A few specialized programs, especially older ones or full-screen applications, do not respond to these shortcuts. If Alt+F4 or Command+W fails after you have checked for dialog boxes, try clicking the X button in the top corner of the window instead. You can also try the menu: on Windows, open the File menu (Alt+F opens it) and look for Close or Exit. On Mac, use the menu bar at the top of the screen.
Web browsers sometimes have extensions or settings that prevent closing the last window. If you cannot close your browser window with Command+W on Mac, try Command+Q to quit the entire browser instead.
Closing multiple windows at once
If you have many windows open and want to shut them all down, close the program entirely instead of closing windows one at a time. On Windows, press Alt+F4 when you are in the program — it will close all remaining windows and quit. On Mac, press Command+Q. Both shortcuts ask you to save any unsaved work before closing.
On Windows, you can also press Alt+Tab to cycle through open windows and see what you have running. This helps you decide whether to close individual windows or the whole program. On Mac, press Command+Tab to see open programs, or Command+` (backtick, the key left of 1) to cycle through windows in the current program.
Closing windows in web browsers
Web browsers treat tabs and windows differently. Command+W on Mac or Ctrl+W on Windows closes the current tab, not the whole browser window. If you have one tab open, closing that tab also closes the window. If you have multiple tabs, only the active tab closes.
To close the entire browser window with all its tabs, use Alt+F4 on Windows or Command+W again — but only after you have closed all tabs, or use Command+Q on Mac to quit the browser entirely. Most people find it faster to just quit the browser (Alt+F4 on Windows, Command+Q on Mac) rather than closing tabs one by one.
If you accidentally close a tab, you can undo it. Press Ctrl+Shift+T on Windows or Command+Shift+T on Mac to reopen the last closed tab. This works multiple times if you closed several tabs in a row.
Keyboard shortcuts for other window tasks
Beyond closing, keyboard shortcuts let you move between windows without the mouse. On Windows, press Alt+Tab to cycle through open windows in the order you used them. Hold Alt and press Tab multiple times to move forward, or Alt+Shift+Tab to move backward. On Mac, press Command+Tab to switch between programs, or Command+` to switch between windows in the same program.
You can also minimize windows with the keyboard. On Windows, press Alt+F9 to minimize the active window. On Mac, press Command+M. To restore a minimized window, click its icon in the taskbar on Windows or the Dock on Mac — there is no keyboard-only way to restore on most systems.
Some programs add their own shortcuts. For example, many text editors use Ctrl+W to close a tab or document instead of the window itself. Check the Help menu or the program's settings if the standard shortcuts do not work the way you expect.
Why keyboard shortcuts matter for your workflow
Switching between the keyboard and mouse breaks your rhythm. Every time you reach for the mouse, you lose a fraction of a second — but across a full workday, those fractions add up to minutes of wasted time. People who work with documents, code, or spreadsheets often find that learning a handful of window shortcuts cuts their daily mouse use in half.
The muscle memory builds quickly. After a week of using Alt+F4 or Command+W instead of clicking the X button, your fingers will do it automatically. You will stop thinking about it and just close windows the way you close doors — without looking.
Frequently Asked Questions
What is the difference between closing a window and closing a program?
Closing a window closes one specific window, but the program keeps running in the background. Closing a program shuts down the entire process and all its windows. If you have two browser windows open and close one with Command+W on Mac, the other stays open. If you press Command+Q, both close and the browser quits.
Will Alt+F4 or Command+W delete my work?
No. If you have unsaved changes, the program will ask you to save before closing. You will see a dialog box asking whether to save, discard, or cancel. You can press Tab to move between buttons and Enter to choose. If you press Cancel, the window stays open and your work is safe.
Can I close a window without saving?
Yes. When the save dialog appears, select "Don't Save" or "Discard" and press Enter. Your unsaved changes will be lost, so use this only when you are sure. If you change your mind, press Cancel instead to go back to the window.
Why does Alt+F4 not work in some programs?
Some programs, especially games or full-screen applications, override the standard shortcuts. Try clicking the X button in the top corner of the window instead. If that does not work, press Escape to exit full-screen mode first, then try Alt+F4 again.
Can I set up my own keyboard shortcut to close windows?
On Windows, you can create custom shortcuts in some programs through Settings or Preferences, but most programs do not allow you to change the Alt+F4 shortcut itself. On Mac, you can add custom shortcuts through System Preferences > Keyboard > Shortcuts, though this is rarely necessary since Command+W is standard across all applications.