The universal shortcut for closing the active window on Windows is Alt + F4. On macOS, it is Command (⌘) + W. These close the window you are currently using, not necessarily the whole application. On Windows, Alt + F4 closes the entire app if it is the last window; on macOS, ⌘W closes a window but leaves the app running. This guide walks you through using these shortcuts correctly, plus alternatives and fixes for when they do not work as expected.

What You'll Need

  • A computer running Windows or macOS (steps for Linux are mentioned where relevant).
  • A physical keyboard (or an on-screen keyboard if you are using a touch-only device).
  • Basic familiarity with your operating system's window management.

Step-by-Step

  1. Identify the active window. Click once on the window you want to close so its title bar is highlighted. The shortcut always acts on the frontmost window.
  2. On Windows, press Alt + F4. Hold the Alt key, then tap F4. The window closes immediately. If it is the only window of that application, the app exits.
  3. On macOS, press Command + W. Hold the Command key (⌘), then press W. The window closes, but the application usually stays open in the Dock. To quit the app entirely, use Command + Q.
  4. For a browser tab instead of a whole window, use Ctrl + W (Windows) or Command + W (macOS). This closes the current tab. If it is the last tab, the browser window closes.
  5. To close a window without a keyboard, click the X button (Windows) or the red close button (macOS) in the top corner. This is the mouse equivalent of the shortcut.
  6. If you are on Linux with a desktop environment like GNOME or KDE, the common shortcut is Alt + F4 as well. Some window managers use Super + Q or Ctrl + Q; check your desktop's keyboard settings if Alt + F4 does nothing.
  7. To close all windows of the same app quickly on Windows, press Alt + F4 repeatedly while the app is focused. Each press closes one window. On macOS, you can press Command + Option + W to close all windows of the front app.

Common Mistakes

  • Using Alt + F4 on a Mac. That combination does not close windows on macOS; use Command + W instead.
  • Expecting Command + W to quit the app. On macOS, it only closes the window. The app remains running; use Command + Q to quit.
  • Pressing Ctrl + W in a non-browser app. In many text editors and IDEs, Ctrl + W closes the current document or tab, not the whole window. Check the app's own shortcuts.
  • Forgetting that Alt + F4 can close the entire application. If you have unsaved work, you may lose it. Save before closing.
  • Assuming the shortcut works in full-screen games or remote desktop sessions. Some full-screen applications capture Alt + F4 and ignore it; use the in-app exit option instead.

Tips

  • On Windows, you can also close a window by right-clicking its taskbar icon and choosing Close window.
  • On macOS, the red close button only closes the window; to quit the app, use the app menu or Command + Q.
  • If you frequently close many windows, learn the difference between closing a window and quitting an app to avoid accidental data loss.
  • In web browsers, Ctrl + Shift + W (Windows) or Command + Shift + W (macOS) closes the entire browser window, not just the tab.
  • For touch devices, the on-screen keyboard may not have function keys; use the window's close button instead.

Troubleshooting

If the shortcut does not close the window, work through these checks in order:

  1. Make sure the window is active. Click its title bar first. The shortcut only works on the frontmost window.
  2. Check for stuck keys or a keyboard layout issue. Try the shortcut again slowly. On Windows, you can use the On-Screen Keyboard (search for it in the Start menu) to test Alt + F4.
  3. Try the mouse alternative. Click the X or red button. If that also fails, the application may be frozen.
  4. Force quit the frozen app. On Windows, press Ctrl + Shift + Esc to open Task Manager, select the app, and click End task. On macOS, press Command + Option + Esc, select the app, and click Force Quit. Unsaved changes will be lost.
  5. Restart the computer. A restart clears temporary glitches that can block keyboard shortcuts.
  6. Check for keyboard software conflicts. Some third-party utilities remap keys. Temporarily disable them or check their settings.

Frequently Asked Questions

What is the shortcut to close a window on Windows?

Alt + F4 closes the active window. If it is the last window of the application, the app exits.

What is the shortcut to close a window on Mac?

Command + W closes the front window. To quit the app entirely, use Command + Q.

How do I close a browser tab instead of the whole window?

Use Ctrl + W (Windows) or Command + W (macOS) to close the current tab. If it is the last tab, the browser window closes.

Why does Alt + F4 not work in some games?

Full-screen games often capture that key combination. Use the game's own exit menu or press Alt + Tab to switch out, then close the window.

Can I close all windows of an app at once?

On macOS, Command + Option + W closes all windows of the front app. On Windows, you can press Alt + F4 repeatedly or use Task Manager to end the app.

Is there a shortcut to close a window on Linux?

Most desktop environments use Alt + F4, but some window managers use different combinations. Check your desktop's keyboard settings.