diff --git a/src/quick/scenegraph/qsgrenderloop.cpp b/src/quick/scenegraph/qsgrenderloop.cpp
index 0cc2a15c51bfd3b9b16620c0fdd229b5d8e803d8..9c39ef65f9961ca422679771f65ca1db66a99c8b 100644
--- a/src/quick/scenegraph/qsgrenderloop.cpp
+++ b/src/quick/scenegraph/qsgrenderloop.cpp
@@ -242,6 +242,7 @@ void QSGGuiThreadRenderLoop::hide(QQuickWindow *window)
     if (m_windows.size() == 0) {
         if (!cd->persistentSceneGraph) {
             rc->invalidate();
+            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
             if (!cd->persistentGLContext) {
                 delete gl;
                 gl = 0;
@@ -255,6 +256,7 @@ void QSGGuiThreadRenderLoop::windowDestroyed(QQuickWindow *window)
     hide(window);
     if (m_windows.size() == 0) {
         rc->invalidate();
+        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
         delete gl;
         gl = 0;
     }
diff --git a/src/quick/scenegraph/qsgwindowsrenderloop.cpp b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
index d5d12bd138199f85dc66a3702c9eee1290f6d8ed..03ee4992bc03a9f9fd12e6db1fd321ad77acd2f8 100644
--- a/src/quick/scenegraph/qsgwindowsrenderloop.cpp
+++ b/src/quick/scenegraph/qsgwindowsrenderloop.cpp
@@ -241,6 +241,7 @@ void QSGWindowsRenderLoop::hide(QQuickWindow *window)
     if (m_windows.size() == 0) {
         if (!cd->persistentSceneGraph) {
             QQuickWindowPrivate::get(window)->context->invalidate();
+            QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
             if (!cd->persistentGLContext) {
                 delete m_gl;
                 m_gl = 0;
@@ -257,6 +258,7 @@ void QSGWindowsRenderLoop::windowDestroyed(QQuickWindow *window)
     // If this is the last tracked window, clean up SG and GL.
     if (m_windows.size() == 0) {
         QQuickWindowPrivate::get(window)->context->invalidate();
+        QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
         delete m_gl;
         m_gl = 0;
     }