             alert.addButtonWithTitle(NSLocalizedString("I confirm, close it.", comment: ""))
             alert.beginSheetModalForWindow(self.window!, completionHandler: { (returnCode) in
                 if (returnCode == NSAlertSecondButtonReturn) {
-                    pane.removeFromSuperview()
+                    self.remove(paneView: pane)
                 }
             })
+        }
+        else {
+            self.remove(paneView: pane)
+        }
+    }
+    
+    private func remove(paneView pane: PaneView) {
+        let parentSplitView = pane.parentSplitView()
+        if parentSplitView?.allSubPaneViews().count == 1 {
+            parentSplitView?.removeFromSuperview()
         }
         else {
             pane.removeFromSuperview()

//            self.setPosition(pos, ofDividerAtIndex: newPaneViewIndex)
        }
        
//        newSplitView.window?.makeFirstResponder(newPaneView)
    }
    
    // MARK: - Helpers

    }
}

// MARK: Alert

private extension NSAlert {
    static func alertForMinimumSplitAdditionalExtension(minimumAdditionalExtension: CGFloat,
