Fix crash when the destructor is called before onInitialize