Fixes infinite loop in process_flush_queues