Issue #3584. If pipe is synch, use synch write

When pipe used for stdout or stderr on Windows,
pip does not allow IOCP. In this case do write
on calling thread.
Added test test-child-process-stdout-flush-exit