In at least one instance the problems occurred as follows:
WinSCP console interface was started from within another application, which redirects output (possibly also input) of the console to some kind of stream, so it can read it.
Problem is that the application waits for WinSCP console process to terminate before starting reading.
The stream created by the application has buffer of some size. So once WinSCP writes enough output, so the buffer gets filled, WinSCP console interface hangs on the next attempt to write. Consequently WinSCP times out waiting for the console interface to complete the write request and reports an error.