Fix onDestroy crash (fix #29)