Fix a bug that prevented entities deleting during the destructor of another entity from being removed.