diff --git a/terminus-ssh/src/api.ts b/terminus-ssh/src/api.ts index 56f8c1d8..3f62cf4a 100644 --- a/terminus-ssh/src/api.ts +++ b/terminus-ssh/src/api.ts @@ -87,6 +87,13 @@ export class SSHSession extends BaseSession { constructor (public connection: SSHConnection) { super() this.scripts = connection.scripts || [] + this.destroyed$.subscribe(() => { + for (const port of this.forwardedPorts) { + if (port.type === PortForwardType.Local) { + port.stopLocalListener() + } + } + }) } async start (): Promise {