Make async write close the stream on error