--- a/src/shell-app.c
+++ b/src/shell-app.c
@@ -899,7 +901,8 @@ shell_app_state_transition (ShellApp
                       state == SHELL_APP_STATE_STARTING));
   app->state = state;
 
-  if (app->state == SHELL_APP_STATE_STOPPED && app->running_state)
+  if (app->state == SHELL_APP_STATE_STOPPED && app->running_state &&
+    app->running_state->windows == NULL)
     {
       unref_running_state (app->running_state);
       app->running_state = NULL;
