diff --git a/window.py b/window.py
index 51cdeba..6c18c9b 100644
--- a/window.py
+++ b/window.py
@@ -139,6 +139,8 @@ class ContainerWidget(Widget):
         assert child.parent is self
         child.parent = None
         self.children.remove(child)
+        if self.focusedChild == child:
+            self.changeFocus()
         self.repaint()
 
     def filthy(self):
