Fix test-version on Windows

It turns out that when we call process.exit there might still be
characters in the buffer. Wait until the buffer is empty before
exiting.