def METHOD_NAME(self, name):
    try:
        self.terminate()
    except Exception:
        logging.warning(
            "%s: error gracefully terminating %s (pid %d)", PROG, name, self.pid
        )
        self.silent_kill()
    else:
        try:
            self.wait(timeout=5)
        except subprocess.TimeoutExpired:
            logging.warning(
                "%s: timeout gracefully terminating %s (pid %d)",
                PROG,
                name,
                self.pid,
            )
            self.silent_kill()