diff --git a/macos/Sources/Features/Terminal/BaseTerminalController.swift b/macos/Sources/Features/Terminal/BaseTerminalController.swift index bda6d62bf5..8e35459da4 100644 --- a/macos/Sources/Features/Terminal/BaseTerminalController.swift +++ b/macos/Sources/Features/Terminal/BaseTerminalController.swift @@ -452,7 +452,16 @@ class BaseTerminalController: NSWindowController, self.alert = nil switch (response) { case .alertFirstButtonReturn: + if let windows = window.tabGroup?.windows, windows.count > 1 { + let secondLastWindow = windows[windows.count - 2] + secondLastWindow.makeKeyAndOrderFront(nil) + secondLastWindow.makeFirstResponder(nil) + + window.close() + } + window.close() + default: break