code: def _run_cmdfinalization_hooks(self, stop: bool, statement: Optional[Statement]) -> bool:
          
  
          with self.sigint_protection:
              if not sys.platform.startswith('win') and self.stdout.isatty():
                  # Before the next command runs, fix any terminal problems like those
                  # caused by certain binary characters having been printed to it.
                  import subprocess
                  proc = subprocess.Popen(['stty', 'sane'])
                  proc.communicate()
  
          try:
              data = plugin.CommandFinalizationData(stop, statement)
              for func in self._cmdfinalization_hooks:
                  data = func(data)
              # retrieve the final value of stop, ignoring any
              # modifications to the statement
              return data.stop
          except Exception as ex:
              self.perror(ex)
docs: Run the command finalization hooks