Drain queues where appropriate to avoid race conditions

We have a theory that these two places require checks to ensure the queue is
drained/processed before continuing, to avoid a potential race.

Signed-off-by: Ken Barber <ken@bob.sh>