Fixes a boundary case where the WQ master can get stuck if there
are only finished tasks to retrieve and nothing else happening in the system.
Replaced boilerplate.