def METHOD_NAME(
    self, exit_config: str = "exit", pattern: str = r"exit"
) -> str:
    """Exit configuration mode"""
    output = ""
    if self.check_config_mode():
        output = self._send_command_timing_str(
            exit_config, strip_prompt=False, strip_command=False
        )
        if "Cannot exit: configuration modified" in output:
            output += self._send_command_timing_str(
                "exit discard", strip_prompt=False, strip_command=False
            )
        if self.check_config_mode():
            raise ValueError("Failed to exit configuration mode")
    return output