code: def leave_command_mode(self, append_to_history=False):
          
          client_state = self.get_client_state()
  
          client_state.command_buffer.reset(append_to_history=append_to_history)
          client_state.prompt_buffer.reset(append_to_history=True)
  
          client_state.prompt_command = ''
          client_state.confirm_command = ''
  
          client_state.app.layout.focus_previous()
docs: Leave the command/prompt mode.