diff --git a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts index 353cdc012783d..300797a5f9b86 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalEditorService.ts @@ -64,6 +64,11 @@ export class TerminalEditorService extends Disposable implements ITerminalEditor } })); this._register(this.onDidDisposeInstance(instance => this.detachInstance(instance))); + this._register(this._editorService.onDidCloseEditor(editor => { + if (editor instanceof TerminalEditorInput && editor.terminalInstance) { + this.detachInstance(editor.terminalInstance); + } + })); } private _getActiveTerminalEditors(): IEditorInput[] {