Fixed a crash caused by entity->destroy()