diff --git a/src/shell-app.c b/src/shell-app.c
index 0455f42..7db8347 100644
--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -849,6 +849,7 @@ static void
 shell_app_on_unmanaged (MetaWindow      *window,
                         ShellApp *app)
 {
+  g_print ("shell-app: Got unmanaged signal for window %p (%s)\n", window, meta_window_get_title (window));
   _shell_app_remove_window (app, window);
 }
 
@@ -932,6 +933,8 @@ _shell_app_remove_window (ShellApp   *app,
   g_object_unref (window);
   app->running_state->windows = g_slist_remove (app->running_state->windows, window);
 
+  g_print ("shell-app: Removing window %p (%s)\n", window, meta_window_get_title (window));
+
   if (app->running_state->windows == NULL)
     shell_app_state_transition (app, SHELL_APP_STATE_STOPPED);
 
@@ -1335,7 +1338,7 @@ shell_app_dispose (GObject *object)
 
   if (app->running_state)
     {
-      while (app->running_state->windows)
+      while (app->running_state && app->running_state->windows)
         _shell_app_remove_window (app, app->running_state->windows->data);
     }
 
diff --git a/src/shell-window-tracker.c b/src/shell-window-tracker.c
index 3ad7dd4..d0ea945 100644
--- a/src/shell-window-tracker.c
+++ b/src/shell-window-tracker.c
@@ -486,6 +486,8 @@ disassociate_window (ShellWindowTracker   *self,
   if (!app)
     return;
 
+  g_print ("shell-window-tracker: Got unmanaged signal for window %p (%s)\n", window, meta_window_get_title (window));
+
   g_object_ref (app);
 
   g_hash_table_remove (self->window_to_app, window);
