diff --git a/src/backend.cmod b/src/backend.cmod
index 56e10ca98a668ec387167c10453c68ccbd6d3b67..1cc2d861f89814eeffb9b92e73d419ebda0992de 100644
--- a/src/backend.cmod
+++ b/src/backend.cmod
@@ -2391,11 +2391,7 @@ PIKECLASS Backend
 	  really_free_compat_cb_box ((struct compat_cb_box *) box);
 	}
 
-	if (box->backend) {
-	  box->backend = NULL;
-	  if (box->ref_obj && box->events)
-	    free_object (box->ref_obj);
-	}
+	unhook_fd_callback_box(box);
       }
 
       free(me->fd_boxes);
@@ -2411,11 +2407,7 @@ PIKECLASS Backend
 	  Pike_fatal ("Got inactive callback in compat interface.\n");
 #endif
 
-	if (box->backend) {
-	  box->backend = NULL;
-	  if (box->ref_obj && box->events)
-	    free_object (box->ref_obj);
-	}
+	unhook_fd_callback_box(box);
       }
 
       free(me->inactive_boxes);