Streams: Add _flush capability to writable streams

Allows writable streams to define a `_flush()` method that can delay the `finish` event until it completes.

See #7348