22. October 2025 1 min read

Visual Studio Code closes workspace when you put its window in background

When you have Visual Studio Code open and you switch to another application, the workspace in VS Code closes unexpectedly. This issue has been reported by multiple users and seems to occur when the VS Code window is sent to the background. This disrupts the workflow, but the real problem is, that you have another instance of VS Code running in the background, which you have to close manually. I have discovered this by running:

ps aux | grep code

With this command you will see multiple instances of code processes running. To resolve this issue, you should just kill the existing running instances of the Visual Studio Code and then run a new instance.

kill -9 processidfrompreviouscommand

This should prevent the workspace from closing when you switch to another application. If the problem persists, consider reinstalling Visual Studio Code or checking for updates that may address this issue.

Newest from this category: