--- composite/compwindow.c.orig	2023-03-29 08:35:36.622935000 -0400
+++ composite/compwindow.c	2023-03-29 08:36:34.403896000 -0400
@@ -613,6 +613,11 @@
     ret = (*pScreen->DestroyWindow) (pWin);
     cs->DestroyWindow = pScreen->DestroyWindow;
     pScreen->DestroyWindow = compDestroyWindow;
+
+    /* Did we just destroy the overlay window? */
+    if (pWin == cs->pOverlayWin)
+        cs->pOverlayWin = NULL;
+
 /*    compCheckTree (pWin->drawable.pScreen); can't check -- tree isn't good*/
     return ret;
 }
