You could have each worker output a poison pill as...
# coroutines
m
You could have each worker output a poison pill as it ends (e.g. -1 or whatever), or just simply take exactly as many things out as you put into the first queue.