[FIX] “Window Terminated Unexpectedly” Error in Visual Studio Code
The “window terminated unexpectedly” error in Visual Studio Code occurs when one of the Electron renderer processes crashes or is forcefully shut down by the system. Visual Studio Code is built on Electron, which uses Chromium (like a browser) to render the interface. Each window runs in a separate renderer process.
You may encounter different error codes such as:
- reason: ‘crashed’, code: ‘1073741819’ or ‘6’
- reason: ‘oom’ (Out of Memory), code: ‘-536870904’
- reason: ‘killed’, code: ‘9’
These errors are often caused by outdated graphics drivers, problematic extensions, Electron or Chromium bugs, corrupted cache or backup files, or even a specific project file crashing the window.
Now that you understand the error codes and possible causes, here are several working solutions:
1. Restart Your Computer
Restarting your system can resolve this error by clearing frozen or unstable processes. Since Visual Studio Code runs its interface using Electron, a crash in its background renderer can be cleared after a full reboot.
Restarting also refreshes GPU drivers and reinitializes memory resources, which helps if the issue is tied to memory overload or driver instability.
- Click the Start menu > Power > Restart.
2. Delete the Backup Folder
VS Code stores unsaved changes in a backup folder. If this folder becomes corrupted, it may cause crashes on launch.
Warning: This will remove any unsaved work from your previous sessions.
- Press Windows + R, type %appdata%, and press Enter.
- Navigate to Code > Backups and delete the entire folder.
- Restart Visual Studio Code and check if it starts normally.
3. Disable the Chromium Sandbox (Advanced)
Electron apps like VS Code use Chromium’s sandbox for process isolation and security. However, in rare cases, this sandbox can conflict with your system and trigger renderer crashes.
Warning: Disabling the Chromium sandbox reduces security protections. Only use this workaround temporarily and in a trusted environment.
- Close all VS Code windows.
- Open Command Prompt as Administrator.
- Type the following command and press Enter:
code --disable-chromium-sandbox
- Reopen your project in VS Code and check if the issue is resolved.
4. Force Close VS Code
Sometimes, background processes from previous sessions continue to run even after you close the window. Force-closing these processes ensures VS Code restarts fresh.
- Press Ctrl + Shift + Esc to open Task Manager.
- Under the Processes tab, locate Visual Studio Code.
- Right-click it and select End Task.
- Restart Visual Studio Code normally.
5. Reinstall the Latest Version of VS Code
A clean installation ensures all Electron and Chromium components are updated and no residual corrupted files remain from a previous version.
- Uninstall Visual Studio Code from your system.
- Delete leftover files at
C:\Users\<YourName>\AppData\Roaming\Code
. - Download the latest version from the official VS Code website and reinstall it.