refactor close and reconnect on a connection handle