Fix disconnecting the client when disconnected from the network
Ensure the handler is cleaned up when a network disconnects