stream: End writables before emitting 'end' event

There was a timing issue b/w the internal callback for ending writable
and the user callback of 'end' event because both of them used the same
'end' event.

So this failed:

    reader.pipe(writer);
    reader.on('end', function() {
      writer.end('Goodbye\n');  // should be failed
    });

But this succeeded:

    reader.on('end', function() {
      writer.end('Goodbye\n');  // should be failed
    });
    reader.pipe(writer);

This commit ends writables not using 'end' event.

Fixes #5603