          logger.debug("Terminating wrapper")
          if self.command == "train":
              logger.debug("Sending Exit Signal")
              print("Sending Exit Signal", flush=True)
              if os.name == "nt":
                  try:
                      logger.debug("Sending carriage return to process")
                      self.process.communicate(input="\n", timeout=timeout)
 
</s> remove             try:
 </s> add             if os.name == "nt":
                try:
                    logger.debug("Sending carriage return to process")
                    self.process.communicate(input="\n", timeout=timeout)
                except TimeoutExpired:
                    logger.error("Timeout reached sending Exit Signal")
                    self.terminate_all_children()
            else:
                logger.debug("Sending SIGINT to process") </s> remove                 if os.name == "nt":
                    try:
                        logger.debug("Sending carriage return to process")
                        self.process.communicate(input="\n", timeout=60)
                    except TimeoutExpired:
                        raise ValueError("Timeout reached sending Exit Signal")
                else:
                    logger.debug("Sending SIGINT to process")
                    self.process.send_signal(signal.SIGINT)
                    while True:
                        timeelapsed = time() - now
                        if self.process.poll() is not None:
                            break
                        if timeelapsed > 60:
                            raise ValueError("Timeout reached sending Exit Signal")
 </s> add                 self.process.send_signal(signal.SIGINT)
                while True:
                    timeelapsed = time() - now
                    if self.process.poll() is not None:
                        break
                    if timeelapsed > timeout:
                        logger.error("Timeout reached sending Exit Signal")
                        self.terminate_all_children() </s> remove         btngen.pack(side=tk.RIGHT, padx=5)
 </s> add         btngen.pack(side=tk.LEFT, padx=5)
        if self.command == "train":
            self.add_timeout(actframe) </s> remove             except ValueError as err:
                logger.error("Error terminating process", exc_info=True)
                print(err)
 </s> add  </s> remove             logger.debug("Termination timed out. Killing Process...")
            print("Termination timed out. Killing Process...")
 </s> add     @staticmethod
    def terminate_all_children():
        """ Terminates all children """
        logger.debug("Terminating Process...")
        print("Terminating Process...", flush=True)
        children = psutil.Process().children(recursive=True)
        for child in children:
            child.terminate()
        _, alive = psutil.wait_procs(children, timeout=10)
        if not alive:
            logger.debug("Terminated")
            print("Terminated")
            return

        logger.debug("Termination timed out. Killing Process...")
        print("Termination timed out. Killing Process...", flush=True)
        for child in alive:
            child.kill()
        _, alive = psutil.wait_procs(alive, timeout=10)
        if not alive:
            logger.debug("Killed")
            print("Killed")
        else:
            timeout = get_config().tk_vars["traintimeout"].get()
          logger.debug("Terminating wrapper")
          if self.command == "train":
            timeout = get_config().tk_vars["traintimeout"].get()
              logger.debug("Sending Exit Signal")
              print("Sending Exit Signal", flush=True)
              if os.name == "nt":
                  try:
                      logger.debug("Sending carriage return to process")
                      self.process.communicate(input="\n", timeout=timeout)
keep add keep keep keep keep keep keep
 Add timeout slider to train tab. Terminate properly on timeout 
lib/gui/wrapper.py