Fixes to shutdown handshaking