def close(self):
        """
        Note:
        Instead of calling this func directly, close Engine by using engine_utils.close_engine
        """
        if len(self._managers) > 0:
            for name, manager in self._managers.items():
                setattr(self, name, None)
                if manager is not None:
                    manager.destroy()
        # clear all objects in spawned_object
        # self.clear_objects([id for id in self._spawned_objects.keys()])
        for id, obj in self._spawned_objects.items():
            if id in self._object_policies:
                self._object_policies.pop(id).destroy()
            if id in self._object_tasks:
                self._object_tasks.pop(id).destroy()
            self._clean_color(obj.id)
            obj.destroy()
        for cls, pending_obj in self._dying_objects.items():
            for obj in pending_obj:
                self._clean_color(obj.id)
                obj.destroy()
        self._dying_objects = {}
        if self.main_camera is not None:
            self.main_camera.destroy()
        self.interface.destroy()
        self.close_engine()

        if self.top_down_renderer is not None:
            self.top_down_renderer.close()
            del self.top_down_renderer
            self.top_down_renderer = None

        Randomizable.destroy(self)

        Note:
        Instead of calling this func directly, close Engine by using engine_utils.close_engine
        
metadrive/engine/base_engine.py