def METHOD_NAME(self):
    """
    Must be called when holding the command lock.
    """
    if self._proc.poll() is not None:
        log.debug("%s has terminated", self)
        return
    try:
        self._proc.kill()
    except OSError as e:
        if e.errno != errno.ESRCH:
            raise
        log.debug("%s has terminated", self)