def close(self):
        '''Called when Our wallet was closed or the device removed.'''
        self.logger.info("closing client")
        self.clear_session()
        # Release the device
        self.transport.close()
Called when Our wallet was closed or the device removed.
electrum/plugins/keepkey/clientbase.py