xwayland: Clean up unpaired surfaces
diff --git a/xwayland/window-manager.c b/xwayland/window-manager.c
index 7a042e5..699bade 100644
--- a/xwayland/window-manager.c
+++ b/xwayland/window-manager.c
@@ -681,6 +681,8 @@
 		if (window->surface_id ==
 		    wl_resource_get_id(surface->resource)) {
 			xserver_map_shell_surface(window, surface);
+			window->surface_id = 0;
+			wl_list_remove(&window->link);
 			break;
 		}	
 }
@@ -1120,6 +1122,9 @@
 		window->frame_id = XCB_WINDOW_NONE;
 	}
 
+	if (window->surface_id)
+		wl_list_remove(&window->link);
+
 	hash_table_remove(window->wm->window_hash, window->id);
 	free(window);
 }