diff --git a/static/panes/pane.ts b/static/panes/pane.ts index df260f3cf..2405fdc48 100644 --- a/static/panes/pane.ts +++ b/static/panes/pane.ts @@ -227,7 +227,12 @@ export abstract class Pane { /** Close the pane if the compiler this pane was attached to closes */ protected onCompilerClose(compilerId: number) { if (this.compilerInfo.compilerId === compilerId) { - _.defer(() => this.container.close()); + _.defer(() => { + // Check if container is still valid before attempting to close + if (this.container?.parent && this.container.layoutManager?.isInitialised) { + this.container.close(); + } + }); } }