Knowing how to close VS Code depends on what you want to close: a file tab, an entire editor group, a project folder, a window, or the application itself. Choosing the right option helps you avoid losing unsaved work and makes it easier to return to the right project later. This guide explains how to close Visual Studio Code on Windows, macOS, and Linux, using keyboard shortcuts, menus, and mouse controls.
It also covers what happens when files have unsaved changes, how to close a VS Code workspace without quitting the program, and what to do if the editor becomes unresponsive. Whether you are new to Visual Studio Code or simply need a quick reminder, use the section that matches what you want to close.
How to Close a File or Tab in VS Code
If you want to close one file but keep VS Code open, close its editor tab. In the editor area, click the X on the tab you want to close. You can also right-click the tab and choose Close. This removes the file from the open editor view; it does not delete the file from your computer.
Keyboard shortcuts offer a faster way to close the active editor tab:
- Windows and Linux: Press Ctrl+W.
- macOS: Press Command+W.
The shortcut usually closes the active editor. If you have several files open, the other tabs remain available. You can reopen a file from the Explorer sidebar, use Quick Open, or select it from the File > Open Recent menu.
VS Code may show a dot or indicator on a tab when a file has unsaved changes. Closing that tab does not necessarily discard the edits. Instead, the editor asks whether you want to save the changes, discard them, or cancel the close action. Choose Save to keep your edits, Don't Save to discard them, or Cancel to leave the file open.
How to Close an Editor Group
VS Code lets you split the editor area into multiple groups so you can view files side by side. To close one group, first make sure a file in that group is active. Then use the editor's group controls, or right-click a tab in the group and choose an option such as Close All to close its open editors. The exact options you see can depend on which area or tab you click.
Closing a group is different from closing a single tab. If you close a tab, the group can remain with other tabs. If you close all the tabs in a group, VS Code may remove the empty group or leave the editor area ready for another file. Your source files remain on disk unless you explicitly delete them through the Explorer or your operating system.
To close several tabs quickly, right-click the tab you want to keep and select an option such as Close Others. You can also use the tab context menu to close tabs to the left or right. Check the menu wording before selecting an action, especially if you have unsaved work in multiple files.
How to Close a VS Code Window
If you have more than one VS Code window open, closing a window lets you leave one project while keeping the other windows running. Use the window's close button: the X in the top-right corner on Windows and most Linux desktop environments, or the red close button in the top-left corner on macOS.
You can also close the current window with a keyboard shortcut:
- Windows and Linux: Press Alt+F4, or use Ctrl+Shift+W in VS Code.
- macOS: Press Command+Shift+W to close the window.
On Windows and Linux, Alt+F4 is a standard system shortcut for closing the active window. In VS Code, Ctrl+Shift+W is the shortcut for closing the window as well. On macOS, Command+W normally closes the active window when no separate document window is in use, so use the shortcut shown in VS Code's menus or Keyboard Shortcuts if you need to confirm the behavior for your setup.
When the last VS Code window closes, the application may remain available in the background or quit, depending on your operating system and settings. If you want to be certain that the program has fully exited, use the quit command rather than only closing a window.
How to Quit VS Code Completely
Quitting VS Code closes the application, rather than just one editor tab or project window. Use the application menu for a reliable option. On Windows and Linux, open File and choose Exit or the equivalent quit command shown in your version. On macOS, open the Code menu and choose Quit Visual Studio Code.
The standard keyboard shortcuts for quitting are:
- Windows and Linux: Press Alt+F4 when the VS Code window is active, or use the quit command in the menu.
- macOS: Press Command+Q.
On macOS, remember the difference between Command+W and Command+Q. The first closes a window or editor, depending on the current context; the second quits the application. If you have multiple windows open, quitting closes the VS Code app and its open windows, while closing one window leaves other windows available.
Before quitting, VS Code checks for unsaved changes. If a file has edits that have not been saved, you may see a confirmation prompt. Save important work before exiting, or review each prompt carefully. If you cancel the prompt, the application stays open so you can continue editing.
How to Close a Folder or Workspace Without Quitting
A project folder or workspace is not the same thing as the VS Code application. To stop working in the current project but keep the editor open, use File > Close Folder or the matching workspace command available in your version. VS Code closes the folder from the current window and may show a Welcome page or an empty editor. The program itself remains open.
This is useful when you want to switch projects without closing every VS Code window. After closing the folder, open another project with File > Open Folder, or use File > Open Recent to choose a folder or workspace you have used before. If you opened a saved multi-folder workspace, use the relevant workspace menu command to close it.
Closing a folder does not erase the project or remove its files from your computer. It simply disconnects that folder from the current VS Code window. Any unsaved editor changes may still trigger a prompt, so save or discard them before moving on.
What Happens to Unsaved Changes When You Close VS Code?
VS Code uses prompts and editor indicators to help you spot unsaved work. A small dot or similar marker on a tab generally means the file has changes that have not been written to disk. If you close that tab, close its window, or quit the app, VS Code may ask what you want to do with those changes.
Choose Save when you want to keep the edits. Choose Don't Save only when you are sure you want to discard them. Choose Cancel if you clicked the wrong close command or need more time to review the file. When several files have unsaved edits, read each prompt rather than dismissing them automatically.
VS Code can also keep unsaved editor content available in some situations, but this should not replace saving important work. A crash, power interruption, or settings change can affect recovery. To avoid losing code, use Ctrl+S on Windows and Linux or Command+S on macOS regularly, and consider enabling Auto Save from the File menu if it fits your workflow.
How to Close VS Code When It Is Not Responding
If VS Code is frozen and the normal close button or menu does not work, wait briefly to see whether the editor is busy. A large project, extension startup, or language-server task can temporarily make the interface slow. If it remains unresponsive, use your operating system's force-quit tools as a last resort.
- Windows: Press Ctrl+Shift+Esc to open Task Manager, select Visual Studio Code, and choose End task.
- macOS: Press Option+Command+Esc, select Visual Studio Code, and click Force Quit.
- Linux: Use your desktop environment's system monitor to end the VS Code process, or use a terminal process-management command if you know which process to stop.
Force quitting can cause unsaved changes to be lost, so use it only when the application cannot close normally. When you reopen VS Code, check whether the files you were editing still have the latest changes. If the editor repeatedly freezes, try disabling recently installed extensions or opening VS Code without extensions to identify whether an add-on is contributing to the problem.
Quick Guide: Which Close Option Should You Use?
Use the close command that matches your goal. This avoids closing more than you intended and makes it easier to return to your work:
- Close one file: Click the tab's X or press Ctrl+W on Windows/Linux, or Command+W on macOS.
- Close a project folder: Choose File > Close Folder or the appropriate workspace command.
- Close one VS Code window: Use the window's close button or the window-close shortcut for your operating system.
- Quit VS Code: Choose the app's Exit or Quit command; on macOS, Command+Q is the standard quit shortcut.
- Force close an unresponsive app: Use Task Manager, Force Quit, or your Linux system monitor only if normal closing fails.
Shortcut behavior can vary with operating-system settings, keyboard layouts, and custom VS Code keybindings. To check or change a shortcut, open Keyboard Shortcuts from the VS Code menu and search for actions such as Close Editor, Close Window, or Quit. This is also helpful if a shortcut is intercepted by another app or does not match the instructions for your system.
Conclusion
To close VS Code safely, first decide whether you mean a file tab, a project folder, a window, or the entire application. Use the tab's close button or editor shortcut for one file, close the folder when you want to leave a project, and choose Exit or Quit when you want to shut down VS Code completely. If you have unsaved changes, review the prompt and save anything you need before proceeding. With these options in mind, you can close VS Code on Windows, macOS, or Linux without accidentally closing the wrong thing or losing important work.
Disclaimer: Articles are written by Humans, AI or Both. Verify Important information.