Problem: loses messages on client destruction

This happens because we use two pipes. Solution: flush the msgpipe
before continuing with destruction. If client does a proper handshake
to sign off at server, this guarantees all messages are delivered to
server before destruction is finshed.
Problem: hangs on client shutdown

There are a few different cases; on interrupt, shutdown must not
do any handshaking, as ZeroMQ is terminated and messages won't be
delivered. On normal exit, shutdown must handshake, to not lose
any messages in flight.

Solution: handshake shutdown, unless interrupted, or actor is null,
indicating connection failed.
Merge pull request #186 from hintjens/master

Fixes to shutdown handshaking