Fix: cib: Prevent use-after-free when cleaning up after query operations