There is https://code.visualstudio.com/api/references/extension-manifest#extension-uninstall-hook
When the extension is uninstalled, the logic must check if the monitor bridge server is up. If yes, kill the detached process.