Fix hangs on Windows