The fastest way to close a window

Press Alt + F4 on Windows or Command + W on Mac. That's it. The window in front of you closes immediately. You don't need to find the X button, move your mouse, or click anything — just hold those two keys together for a second and the window is gone.

This works in almost every program: web browsers, email, word processors, file managers, settings windows, everything. The only exceptions are a few older programs or specialized applications that override this shortcut, but those are rare.

If you have multiple windows open in the same program (like several browser tabs or multiple document windows), Alt + F4 or Command + W closes only the one you're currently using, not the whole program. The program stays open in the background.

Key Takeaways

  • Alt + F4 on Windows and Command + W on Mac close the active window instantly without using your mouse.
  • These shortcuts work in nearly all programs, from browsers to word processors to system settings.
  • Closing a window is different from closing a program — the program may continue running in the background.
  • If a window won't close with the keyboard shortcut, the program may be frozen and need to be force-quit instead.

When Alt + F4 doesn't work

Sometimes you'll press Alt + F4 and nothing happens. This usually means the program has stopped responding or is frozen. The keyboard shortcut can't reach a program that isn't listening.

On Windows, use Alt + Tab to switch to the frozen window and make sure it's actually selected, then try Alt + F4 again. If that still doesn't work, you'll need to force-quit the program. Press Ctrl + Alt + Delete, select Task Manager, find the program in the list, click it, and then click "End Task" at the bottom right.

On Mac, press Command + Option + Escape to open the Force Quit window. Find the program that won't close, select it, and click "Force Quit." This is Mac's version of ending a frozen program.

Closing a program instead of just a window

If you want to close the entire program (not just one window), use Alt + F4 on Windows when it's the last window open, or use Command + Q on Mac. Command + Q closes the whole program no matter how many windows it has open.

On Windows, Alt + F4 closes windows one at a time. If you have three browser windows open and press Alt + F4 three times, you'll close all three and the browser will shut down. But if you only press it once, just the front window closes and the browser keeps running.

Mac's Command + Q is more direct — it closes everything at once. If you want to close just one window on Mac without closing the whole program, use Command + W instead.

Why use the keyboard instead of clicking the X

The keyboard shortcut is faster than moving your mouse to the corner of the window and clicking the X button, especially if your hands are already on the keyboard. It's one quick motion instead of reaching for the mouse, finding the button, and clicking it.

The shortcut also works the same way in every program, so once you learn it, you don't have to think about where the close button is. On some programs the X is in the top right corner, on others it's in the top left, and on some it's hidden in a menu. The keyboard shortcut is always the same.

If you're using a laptop trackpad and find it awkward to use, the keyboard shortcut becomes even more useful. You can close windows without taking your hands off the keyboard at all.

Other window shortcuts worth knowing

Once you're comfortable with Alt + F4 or Command + W, a few other keyboard shortcuts make window management faster. Alt + Tab on Windows and Command + Tab on Mac let you switch between open programs without touching the mouse. Hold the key combination and keep pressing Tab to cycle through your programs.

On Windows, Windows key + Left Arrow snaps the current window to the left half of your screen, and Windows key + Right Arrow snaps it to the right half. This is useful when you want to see two windows side by side. Mac doesn't have a built-in keyboard shortcut for this, but many Mac users install third-party apps to add the feature.

Alt + Tab + Shift on Windows cycles through programs in reverse order if you overshoot the one you want. On Mac, Command + Tab + Shift does the same thing.

Troubleshooting when the shortcut feels stuck

If you press Alt + F4 and the window closes but then immediately reopens, the program may be set to restore your previous session. This is common in web browsers — they're designed to remember what you had open. Closing the window doesn't actually shut down the browser, so it reopens the window automatically.

To actually close the browser completely, use Alt + F4 on the last remaining window, or use the File menu and select Exit or Quit. Some browsers also have a setting to disable session restore, which you can find in the preferences or settings menu.

If a window closes and then a new one opens in its place, check whether the program is set to open a new window on startup. This is different from the window reopening — the program is actually launching fresh. You'll need to close the program itself, not just the window.

Frequently Asked Questions

Does Alt + F4 work on all computers?

Alt + F4 works on any Windows computer. On Mac, use Command + W instead — Macs don't respond to Alt + F4. If you use both Windows and Mac, remember that Windows uses Alt and Mac uses Command for most shortcuts.

What's the difference between closing a window and closing a program?

Closing a window closes one specific window, but the program may still be running in the background. Closing a program shuts down the entire application. On Windows, Alt + F4 closes the window; if it's the last window, the program closes too. On Mac, Command + W closes the window and Command + Q closes the program.

Can I undo closing a window?

Not directly — once the window is closed, it's gone. However, many programs like web browsers let you reopen recently closed windows. In most browsers, press Ctrl + Shift + T on Windows or Command + Shift + T on Mac to reopen the last closed tab or window.

Why won't Alt + F4 close my window?

The program may be frozen or not responding. Try clicking on the window first to make sure it's selected, then try Alt + F4 again. If it still doesn't work, use Ctrl + Alt + Delete on Windows or Command + Option + Escape on Mac to force-quit the program.

Is there a keyboard shortcut to close all windows at once?

On Mac, Command + Q closes the entire program and all its windows. On Windows, there's no single shortcut to close all windows at once — you have to close them one by one with Alt + F4, or use Task Manager to end the program.