Fix infinite loop in timeout handling on Windows.