def _finish(self, agent_name, ignore_delay_done=False):
        """
        ignore_delay_done: Whether to ignore the delay done. This is not required when the agent success the episode!
        """
        if not self.engine.replay_episode:
            vehicle_name = self._agent_to_object[agent_name]
            v = self._active_objects.pop(vehicle_name)
            if (not ignore_delay_done) and (self._delay_done > 0):
                self._put_to_dying_queue(v)
            else:
                # move to invisible place
                self._remove_vehicle(v)
            self._agents_finished_this_frame[agent_name] = v.name
            self._check()

        ignore_delay_done: Whether to ignore the delay done. This is not required when the agent success the episode!
        
metadrive/manager/agent_manager.py