diff --git a/pd/src/s_inter.c b/pd/src/s_inter.c
index 75a8ffeb16d1db63e313eec67b7088d62bf4ab1e..78f115ee842ad9ebc4b3fa479689c912126bb5e6 100644
--- a/pd/src/s_inter.c
+++ b/pd/src/s_inter.c
@@ -879,12 +879,13 @@ void sys_unqueuegui(void *client)
     t_guiqueue *gq, *gq2;
     if (!sys_guiqueuehead)
         return;
-    if (sys_guiqueuehead->gq_client == client)
+    while (sys_guiqueuehead->gq_client == client)
     {
-        t_freebytes(sys_guiqueuehead, sizeof(*sys_guiqueuehead));
-        sys_guiqueuehead = 0;
+        gq = sys_guiqueuehead;
+        sys_guiqueuehead = sys_guiqueuehead->gq_next;
+        t_freebytes(gq, sizeof(*gq));
     }
-    else for (gq = sys_guiqueuehead; gq2 = gq->gq_next; gq = gq2)
+    for (gq = sys_guiqueuehead; gq2 = gq->gq_next; gq = gq2)
         if (gq2->gq_client == client)
     {
         gq->gq_next = gq2->gq_next;