docs: def expect_end(self):
          """Wait for the running program to finish.
  
          Returns:
              A tuple with the exit code, as reported by the operating system, and the output produced.
          """
          logger.debug("Waiting for termination of '{0}'".format(self.name))
          try:
              # Make sure we fetch the last output bytes.
              # Recommendation from the pexpect docs.
              self._spawn.expect(pexpect.EOF)
              self._spawn.wait()
              dircontent = str(os.listdir(self.job.working_dir))
              logger.debug("Working directory after execution: " + dircontent)
              return self.get_exitstatus(), self.get_output()
          except pexpect.exceptions.EOF as e:
              logger.debug("Raising termination exception.")
              raise TerminationException(instance=self, real_exception=e, output=self.get_output())
          except pexpect.exceptions.TIMEOUT as e:
              logger.debug("Raising timeout exception.")
              raise TimeoutException(instance=self, real_exception=e, output=self.get_output())
          except Exception as e:
              logger.debug("Waiting for expected program end failed.")
              raise NestedException(instance=self, real_exception=e, output=self.get_output())