stdio: Fix issue #3584. Use synch write in pipe

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