fix deadlock when stopping