There are numerous races of various sorts around destruction of MetadataManager and ScopedCollectionMetadata objects. Fixing them requires changes to ScopedCollectionMetadata and CollectionMetadataTracker layout, and locking in the MetadataManager destructor.
Reproduce by running jstests/sharding/cleanup_orphaned_cmd_during_movechunk.js and jstests/concurrency/fsm_all_simultaneous repeatedly.