util/queue: fix a data race detected by TSAN when finishing the queue
@tarceri Looks like you wrote a similar patch but it didn't fix it by that time, surprising!
EDIT: it actually worked, see the bug ticket for more information.
Edited by Samuel Pitoiset