Fix a weird, rare crash that occasionally appears when removing a particle in the same step as writing a snapshot.