Attempt to fix disconnect not respecting linger

Looks like linger is honoured properly, but shutting down the session
causes the pipe termination to come from that side - because the local
pipe then shuts down right away it seems to trigger a terminated on the
other end instead of waiting. This way we trigger the termination from
the local end and then terminate the session.
Merge pull request #627 from ianbarber/master

Attempt to fix disconnect not respecting linger