Depending on what you're trying to achieve you can write your 'release' code in
- your class destructor
- in AppDelegate::applicationDidEnterBackground() (but I guess this is not what you want)
Note that there's no 'exit' or 'close' application event (iOS does not allow you to exit your app).
On Android though, you might enable the keypad (setKeypadEnabled(true)) and call CCDirector::sharedDirector()->end() when the back key is hit. The onExit method still will be called on your objects.