Crash when closing Panda using ODE TriMeshGeom

I wrestled with this too. It was discussed in a previous thread here: [Panda crashing when removing ODE object)

Don’t use sys.exit. Make a customized cleanup function something like this:

def cleanup_and_exit(world, space):
    for geom in [space.getGeom(i) for i in range(space.getNumGeoms())]:
        geom.destroy()
    space.destroy()
    world.destroy()
    base.userExit()

Technically, OdeSpace.destroy() should automatically destroy all contained geoms but apparently there is a bug there.