stream: Guarantee ordering of 'finish' event

In synchronous Writable streams (where the _write cb is called on the
current tick), the 'finish' event (and thus the end() callback) can in
some cases be called before all the write() callbacks are called.

Use a counter, and have stream.Transform rely on the 'prefinish' event
instead of the 'finish' event.

This has zero effect on most streams, but it corrects an edge case and
makes it perform more deterministically, which is a Good Thing.

Reviewers: We discussed this in our last node-core call, and I'd mentioned just calling this WONTFIX, but it's annoying me more and more, and makes correct behavior of writev harder than necessary to test.  So here this is.