diff -up gnome-screensaver-2.28.1/src/gs-manager.c.dont-dive-on-monitor-removal gnome-screensaver-2.28.1/src/gs-manager.c
--- gnome-screensaver-2.28.1/src/gs-manager.c.dont-dive-on-monitor-removal	2010-01-28 22:06:47.000000000 -0500
+++ gnome-screensaver-2.28.1/src/gs-manager.c	2010-02-04 18:32:31.838280430 -0500
@@ -1478,6 +1478,9 @@ on_screen_monitors_changed (GdkScreen *s
                         gs_manager_create_window_for_monitor (manager, screen, i);
                 }
         } else {
+
+                gdk_x11_grab_server ();
+
                 /* remove the extra windows */
                 l = manager->priv->windows;
                 while (l != NULL) {
@@ -1495,6 +1498,16 @@ on_screen_monitors_changed (GdkScreen *s
                         }
                         l = next;
                 }
+
+                /* make sure there is a lock dialog on a connected monitor,
+                 * and that the keyboard is still properly grabbed after all
+                 * the windows above got destroyed*/
+                if (n_windows > n_monitors) {
+                        gs_manager_request_unlock (manager);
+                }
+
+                gdk_flush ();
+                gdk_x11_ungrab_server ();
         }
 }
 
diff -up gnome-screensaver-2.28.1/src/gs-window-x11.c.dont-dive-on-monitor-removal gnome-screensaver-2.28.1/src/gs-window-x11.c
--- gnome-screensaver-2.28.1/src/gs-window-x11.c.dont-dive-on-monitor-removal	2010-01-28 22:06:47.000000000 -0500
+++ gnome-screensaver-2.28.1/src/gs-window-x11.c	2010-02-04 15:45:32.086465083 -0500
@@ -45,6 +45,8 @@ static void gs_window_init       (GSWind
 static void gs_window_finalize   (GObject       *object);
 
 static gboolean popup_dialog_idle (GSWindow *window);
+static void gs_window_dialog_finish (GSWindow *window);
+static void remove_command_watches (GSWindow *window);
 
 enum {
         DIALOG_RESPONSE_CANCEL,
@@ -927,6 +929,21 @@ gs_window_destroy (GSWindow *window)
 {
         g_return_if_fail (GS_IS_WINDOW (window));
 
+        if (window->priv->lock_pid > 0) {
+                gs_window_dialog_finish (window);
+        }
+
+        remove_popup_dialog_idle (window);
+        remove_command_watches (window);
+        remove_watchdog_timer (window);
+
+        if (window->priv->lock_box != NULL) {
+                gtk_container_remove (GTK_CONTAINER (window->priv->vbox), GTK_WIDGET (window->priv->lock_box));
+                window->priv->lock_box = NULL;
+
+                g_signal_emit (window, signals [DIALOG_DOWN], 0);
+        }
+
         gtk_widget_destroy (GTK_WIDGET (window));
 }
 
