Time-out implementation for Windows

The implementation requires a new thread to be started and definitely can
be improved. But for now, it works pretty well and the timeout test
passes.