fix race condition when stopping server (properly this time)