def attempt_to_close_connection(ssh_client: paramiko.client.SSHClient):
    """Call ssh_client.close() and log exception and cosmobot hostname if it fails"""

    # get hostname up here in case the transport isn't available after a failed close()
    hostname = ssh_client.get_transport().hostname

    try:
        ssh_client.close()
    except Exception as e:
        logging.error(
            f"exception occured while trying to close ssh connection to cosmobot {hostname}"
        )
        logging.exception(e)