Restarting cocos2d-x on iPhone gives pink screen

Hi, I have an app which will lauch the Cocos2d layer separately. I call cocos2d::CCApplication::sharedApplication().run(); to run the game, but when I try to rerun the game (after calling cocos2d::CCApplication::sharedApplication()->end(); at the end of the previous game) I get a pink screen, and OpenGL error 0x0506 in -[EAGLView swapBuffers] error in the LOGs. I’m not sure if the openGl view is being cleared properly and not sure where I can call this…