def METHOD_NAME(self, command: str = "logout") -> None:
    """Gracefully exit the SSH session."""
    # Exit configuration mode.
    try:
        if self.check_config_mode():
            self.exit_config_mode()
    except Exception:
        pass
    # Terminate SSH/telnet session
    self.write_channel(command + self.RETURN)
    output = ""
    for _ in range(10):
        # The connection might be dead here.
        try:
            # "Do you want to log out"
            # "Do you want to save the current"
            pattern = r"Do you want.*"
            new_output = self.read_until_pattern(pattern, read_timeout=1.5)
            output += new_output
            if "Do you want to log out" in new_output:
                self.write_channel("y" + self.RETURN)
                break
            elif "Do you want to save the current" in new_output:
                # Don't automatically save the config (user's responsibility)
                self.write_channel("n" + self.RETURN)
        except socket.error:
            break
        except ReadTimeout:
            break
        except Exception:
            break
        time.sleep(0.05)
    # Set outside of loop
    self._session_log_fin = True