The error “Visual Studio Code Error: The Window Terminated Unexpectedly” appears when VS Code crashes during startup or while running. This issue often relates to a conflict with the Chromium sandbox, a security feature that isolates processes. Although important for safety, the sandbox can sometimes cause instability on certain systems, resulting in unexpected shutdowns. So follow along as we guide you through all the steps you can take to fix this error message on your PC.

Takeaways:

  1. Learn how to fix Visual Studio Code “The Window Terminated Unexpectedly” Error.
  2. What is causing Visual Studio Code “The Window Terminated Unexpectedly” Error on Windows?

How to Fix Visual Studio Code “The Window Terminated Unexpectedly” Error

As with just about every troubleshooting guide, there are quite a few different things you can do to fix this problem, so work your way through the list of potential fixes below. Just make sure you start from the top and work your way down as it's listed in order of success rate.

Launch VS Code Without the Chromium Sandbox

The Chromium sandbox restricts access to system resources for security purposes. If your system or drivers do not fully support it, VS Code may crash during initialisation. Running VS Code without the sandbox can confirm whether this is the cause.

  • Close Visual Studio Code completely.
  • Press Win + R, type cmd, and press Enter.
  • In the Command Prompt, enter:

code --disable-chromium-sandbox

How to Fix Visual Studio Code “The Window Terminated Unexpectedly” Error

  • If VS Code starts successfully, update your operating system and drivers. You may use this option as a temporary workaround if needed.

Clear VS Code Cache and Backup Data

Corrupted cache or backup files may prevent VS Code from launching. Removing them forces VS Code to regenerate clean files.

  • Close all VS Code windows.
  • Press Win + R, type the following path, and press Enter:

%APPDATA%\Code

Delete these folders:

Cache

CachedData

Code Cache

GPUCache

Restart VS Code

Disable Extensions

Extensions can interfere with VS Code’s stability. To check:

  • Press Win + R, type cmd, and press Enter.
  • Run this command.

code --disable-extensions

  • If VS Code starts successfully, one of your extensions is the problem. Re-enable them one at a time to find the faulty one.

Disable Hardware Acceleration

Hardware acceleration uses the GPU for rendering but may cause crashes with certain drivers.

  • Open VS Code.
  • Press Ctrl + Shift + P to open the Command Palette.
  • Search for and select Preferences: Open Settings (JSON).
  • Add this line:

"disable-hardware-acceleration": true

  • Restart VS Code. It will now use CPU rendering.

Reinstall Visual Studio Code

If the issue is still happening, reinstalling VS Code ensures that corrupted or outdated files are replaced.

  • Press Win + R, type appwiz.cpl, and press Enter.
  • Locate Visual Studio Code, right-click, and choose Uninstall.
  • Download the latest version from the official Visual Studio Code website.
  • Install it and restart your system.
  • Launch VS Code to verify that the error is resolved.

Increase Virtual Memory (Paging File)

If your system does not have enough physical RAM, Windows uses virtual memory. A low paging file allocation can cause VS Code to terminate unexpectedly. Increasing this allocation can improve stability. This is probably a waste of time for 99% of people, but if you want to try it, the steps are listed below.

  • Press Win + R, type sysdm.cpl, and press Enter.
  • In the System Properties window, go to the Advanced tab. Under Performance, click Settings.
  • In Performance Options, select the Advanced tab and click Change under Virtual memory.

Fix Visual Studio Code “The Window Terminated Unexpectedly” Error

  • Uncheck Automatically manage paging file size for all drives.
  • Select your system drive (usually C:), choose Custom size, and enter values:
    • Initial size: use the recommended value shown.
    • Maximum size: set a higher value (for example, 4096 MB or more).
  • Click Set, then OK, and restart your computer.

Fix Visual Studio Code The Window Terminated Unexpectedly Error