how to release cocos2d in uikit?

i put EAGLView to an uiview as it’s subview, such as this:

  • (void)runCocos2D
    {
    EAGLView *glView = ;
    *glView.tag = 1000;
    //UIWindow
    win = [[UIApplication sharedApplication] keyWindow];
    [self addSubview:__glView];
    cocos2d::CCApplication::sharedApplication().run();
    }

and i want release cocos2d like it:
void HelloWorld::menuCloseCallback(CCObject* pSender)
{
CCDirector::sharedDirector()->end();
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
//exit(0);
#endif
}

but is was crash when i load the view again.