Permit clean shutdown when remote side terminates connection

Previously this would block.
Merge pull request #20 from lattwood/dev

Permit clean shutdown when remote side terminates connection