async _shutdown()

in src/debugger.js [297:337]


    async _shutdown() {
        const shutdownStart = Date.now();

        // only log this if we started properly
        if (this.ready) {
            log.log();
            log.log();
            log.debug("shutting down...");
        } else {
            log.debug("aborting start - shutting down ...");
        }
        log.spinner("Shutting down");

        // need to shutdown everything even if some fail, hence tryCatch() for each

        if (this.agentMgr) {
            await this.tryCatch(this.agentMgr.shutdown());
        }

        // ------------< critical removal must happen above this line >---------------

        // in VS Code, we will not run beyond this line upon debug stop.
        // this is because invoker.stop() will kill the container & thus close the
        // debug port, upon which VS Code kills the debug process (us)
        if (this.invoker) {
            await this.tryCatch(this.invoker.stop());
        }

        if (this.watcher) {
            // this is not critical on a process exit, only if Debugger is used programmatically
            // and might be reused for a new run()
            await this.tryCatch(this.watcher.stop());
            log.debug("stopped source file watching");
        }

        // only log this if we started properly
        if (this.ready) {
            log.succeed(`Done. Shutdown in ${prettyMilliseconds(Date.now() - shutdownStart)}.`);
        }
        this.ready = false;
    }