Fix race condition when detecting end of websocket tests.