http: Don't emit finish until fully flushed

Closes #5712

When ending, if there is a pending write, don't emit finish until the
subsequent close or drain event, so that we know it's fully flushed.