The fastest way to close a window
The quickest way to close any window on your computer is to click the X button in the top-right corner of that window. On Windows computers, this button appears in the upper right. On Mac computers, it appears in the upper left. One click closes that single window and returns you to whatever was behind it.
If you are using a keyboard, you can close the active window by pressing Alt + F4 on Windows or Command + W on Mac. This works in almost every program — web browsers, word processors, email clients, and file managers all respond to these shortcuts. The keyboard method is faster once you get used to it, especially if your hands are already on the keyboard.
Key Takeaways
- Click the X button in the top corner of any window to close it without closing other windows from the same program.
- Use Alt + F4 on Windows or Command + W on Mac to close the active window from your keyboard.
- Closing a window is different from closing a program — closing the last window of a program usually closes the program too, but not always.
- If a window will not close, you can force it shut using Task Manager on Windows or Activity Monitor on Mac.
- Unsaved work in a closing window will prompt you to save before the window actually closes.
The difference between closing a window and closing a program
When you close a window, you close only that single window. If you have multiple windows open from the same program — say, two browser tabs or two document files — closing one window leaves the others open. The program itself keeps running in the background.
On most Windows programs, closing the last open window also closes the program. On Mac, closing all windows does not always close the program — you may see the program still listed in your dock or in the menu bar. To fully close a Mac program, you need to use Command + Q instead of Command + W, or right-click the program name in the dock and select "Quit."
What happens when you close a window with unsaved work
If you try to close a window that contains unsaved changes — a document you have edited but not saved, an email you have written but not sent — the program will show you a dialog box asking whether you want to save before closing. You will see buttons like "Save," "Don't Save," and sometimes "Cancel." Clicking "Cancel" keeps the window open so you can save your work. Clicking "Don't Save" closes the window and discards your changes.
This safety feature prevents you from accidentally losing work. If you click "Don't Save" by mistake, you cannot undo it after the window closes, so read the dialog carefully before you click. Some programs, like Google Docs or Microsoft 365 online, save automatically as you type, so you may never see this dialog at all.
Closing a frozen or unresponsive window
Sometimes a window stops responding to clicks and keyboard commands. The X button does not work, and Alt + F4 has no effect. On Windows, open Task Manager by pressing Ctrl + Shift + Esc or right-clicking the taskbar and selecting "Task Manager." Find the frozen program in the list, click it once to select it, then click the "End Task" button at the bottom right. The window closes immediately.
On Mac, press Command + Option + Esc to open the Force Quit dialog. Find the frozen program in the list, click it, and click "Force Quit." The window closes right away. Force quitting closes the entire program, not just one window, so you will lose any unsaved work in that program. Use it only when the normal close methods do not work.
Closing multiple windows at once
If you want to close all windows from a single program at once, use the keyboard shortcut to close the entire program instead of closing windows one by one. On Windows, press Alt + F4 while the program is active, or right-click the program in the taskbar and select "Close all windows." On Mac, press Command + Q while the program is active.
If you have unsaved work in any of those windows, the program will ask you to save each one before closing. Some programs offer a "Close All" option in the File menu that lets you save all documents at once. Check the File menu of the program you are using to see what options are available.
Closing windows in web browsers
Web browsers work slightly differently from other programs. Closing a tab (the small labeled area at the top of the browser window) closes only that one webpage. Closing the entire browser window closes all tabs in that window. To close a single tab, click the X on that tab or right-click the tab and select "Close tab." To close the entire browser, click the X on the browser window itself or press Alt + F4 on Windows or Command + Q on Mac.
Most browsers have a feature that remembers your open tabs when you close the browser, so you can reopen them the next time you start the browser. Check your browser settings if you want to change this behavior — some people prefer a fresh start each time, while others want their tabs to return automatically.
Closing windows without using the mouse
If your mouse is not working or you prefer keyboard navigation, you can close windows entirely from the keyboard. Press Alt + F4 on Windows or Command + W on Mac to close the active window. If a save dialog appears, use the Tab key to move between buttons and press Enter to select one. On Windows, you can also press Alt + Space to open the window menu, then press C to close.
Learning these keyboard shortcuts saves time and keeps you from having to reach for the mouse. They work in nearly every program on your computer, so practicing them once means you can use them everywhere.
Frequently Asked Questions
Why does closing a window sometimes close my entire program?
On Windows, closing the last open window of a program usually closes the program too. On Mac, closing all windows does not automatically close the program — you need to press Command + Q or select Quit from the menu. This is by design and varies between operating systems.
Can I undo closing a window?
You cannot undo the act of closing a window, but most programs let you reopen recently closed windows. In web browsers, press Ctrl + Shift + T on Windows or Command + Shift + T on Mac to reopen the last closed tab. In other programs, check the File menu for a "Reopen" or "Recent" option.
What if the X button is not visible on my window?
Some programs run in full-screen mode where the X button is hidden. Press Escape or F11 to exit full-screen mode, which should bring the X button back. If that does not work, use Alt + F4 on Windows or Command + W on Mac to close the window from the keyboard.
Does closing a window delete my files?
Closing a window does not delete files on your computer. It only closes the program window. Your files remain on your hard drive unless you specifically delete them. If you had unsaved changes in a document, those changes are lost, but the original file stays where it was.
Why does my computer ask me to save when I close a window?
The save prompt appears because you made changes to a document that have not been saved to your hard drive yet. The program is giving you a chance to keep those changes before closing. If you click "Don't Save," the changes disappear and only the last saved version of the file remains.