              self.thread.start()
              self.config.root.after(1000, self.terminate)
          elif not self.thread.complete.is_set():
              logger.debug("Not finished terminating")
              self.config.root.after(1000, self.terminate)
          else:
              logger.debug("Termination Complete. Cleaning up")
              _ = self.thread.get_result()  # Terminate the LongRunningTask object
              self.thread = None
  
 
</s> remove             self.thread = LongRunningTask(target=self.terminate_in_thread,
                                          args=(self.command, self.process))
            if self.command == "train":
                self.wrapper.tk_vars.is_training.set(False)
            self.thread.start()
            self.config.root.after(1000, self.terminate)
        elif not self.thread.complete.is_set():
 </s> add             self._thread = LongRunningTask(target=self._terminate_in_thread,
                                           args=(self._command, self._process))
            if self._command == "train":
                get_config().tk_vars.is_training.set(False)
            self._thread.start()
            self._config.root.after(1000, self.terminate)
        elif not self._thread.complete.is_set(): </s> remove             _ = self.thread.get_result()  # Terminate the LongRunningTask object
            self.thread = None
 </s> add             _ = self._thread.get_result()  # Terminate the LongRunningTask object
            self._thread = None

    def _terminate_in_thread(self, command: str, process: Popen) -> bool:
        """ Terminate the subprocess </s> remove     def terminate_in_thread(self, command, process):
        """ Terminate the subprocess """
 </s> add         Parameters
        ----------
        command: str
            The command that is running

        process: :class:`subprocess.Popen`
            The running process

        Returns
        -------
        bool
            ``True`` when this function exits
        """ </s> remove         self.config = get_config()
        self.statusbar = self.config.statusbar
        self.command = None
        self.args = None
        self.process = None
        self.thread = None  # Thread for LongRunningTask termination
        self.train_stats = {"iterations": 0, "timestamp": None}
        self.consoleregex = {
 </s> add         self._config = get_config()
        self._statusbar = self._config.statusbar
        self._command: str | None = None
        self._process: Popen | None = None
        self._thread: LongRunningTask | None = None
        self._train_stats: dict[T.Literal["iterations", "timestamp"],
                                int | float | None] = {"iterations": 0, "timestamp": None}
        self._consoleregex: dict[T.Literal["loss", "tqdm", "ffmpeg"], re.Pattern] = { </s> remove     def terminate(self):
        """ Terminate the running process in a LongRunningTask so we can still
            output to console """
        if self.thread is None:
 </s> add     def terminate(self) -> None:
        """ Terminate the running process in a LongRunningTask so console can still be updated
        console """
        if self._thread is None:
            self._config.root.after(1000, self.terminate)
              self.thread.start()
              self.config.root.after(1000, self.terminate)
          elif not self.thread.complete.is_set():
              logger.debug("Not finished terminating")
            self._config.root.after(1000, self.terminate)
          else:
              logger.debug("Termination Complete. Cleaning up")
              _ = self.thread.get_result()  # Terminate the LongRunningTask object
              self.thread = None
  
keep keep keep keep replace keep keep keep keep keep
 bugfix: GUI force stdout/stderr reading to utf-8 
lib/gui/wrapper.py