def METHOD_NAME(self) -> None:
    if self.closed:
        raise tbot.error.ChannelClosedError
    sid = os.getsid(self.p.pid)
    self.p.terminate()
    os.METHOD_NAME(self.pty_slave)
    os.METHOD_NAME(self.pty_master)
    self.p.wait()
    # Wait for all processes in the session to end.  Most of the time
    # this will return immediately, but in some cases (eg. a serial session
    # with picocom) we have to wait a bit until we can continue.  To be as
    # quick as possible this is implemented as exponential backoff and will
    # give up after 1 second (1.27 to be exact) and emit a warning.
    for t in range(7):
        if (
            subprocess.call(
                ["ps", "-s", str(sid)],
                stdout=subprocess.DEVNULL,
                stderr=subprocess.DEVNULL,
            )
            != 0
        ):
            break
        time.sleep(2**t / 100)
    else:
        raise tbot.error.TbotException("some subprocess(es) did not stop")