There were two separate issues which have a very similar solution:
* When loading the .blend file, the `scene->rigid_body_world->group` collection
pointer has to be mapped to the actual address. However, that was not done
because `BKE_rigidbody_world_id_loop` was a stub when `WITH_BULLET` is off.
That resulted in the collection pointer having an invalid address.
* When closing the file, there was some issue because of incomplete code for
copying rigid body related stuff for the depsgraph and hence there was some
unexpectedly shared ownership which leads to a use-after-free. Here the fix is
to move the copy code out of a `#ifdef WITH_BULLET` block too.
Since none of the moved code actually needs bullet, it seems fine to move it.
The code should be exactly the same in the common case with `WITH_BULLET` is on.
Pull Request: https://projects.blender.org/blender/blender/pulls/132697