src/vs/workbench/browser/parts/panel/panelPart.ts/BasePanelPart/onDidDeregisterPanel
class BasePanelPart:	private async onDidDeregisterPanel(panelId: string): Promise<void> {
		const disposable = this.panelDisposables.get(panelId);
		disposable?.dispose();
		this.panelDisposables.delete(panelId);

		const activeContainers = this.viewDescriptorService.getViewContainersByLocation(this.viewContainerLocation)
			.filter(container => this.viewDescriptorService.getViewContainerModel(container).activeViewDescriptors.length > 0);

		if (activeContainers.length) {
			if (this.getActivePaneComposite()?.getId() === panelId) {
				const defaultPanelId = this.viewDescriptorService.getDefaultViewContainer(this.viewContainerLocation)?.id;
				const containerToOpen = activeContainers.filter(c => c.id === defaultPanelId)[0] || activeContainers[0];
				await this.openPaneComposite(containerToOpen.id);
			}
		} else {
			this.layoutService.setPartHidden(true, this.partId);
		}

		this.removeComposite(panelId);
	}