When to release a CCSpriteBatchNode once the animation is finsihed.

I am playing an animation and want to remove its batch node from the parent (CCLayer) as soon as the animation finishes playing. I am running it as a CCsequence so I have function named animationFinished which get called when it finishes playing. But I can’t remove batch node from parent in this function as it get released and don’t have any other retain. So game crashes, As it is still being used by the engine.

So basically at what event I can release my batch node. If i don’t do so , then it will be added again and again to the CClayer.Please see code below

void GameLayer::playAnimation(const AnimationFileAndTypeInfo &powerFileInfo,float placeAtScreenWidthRatio,float placeAtScreenHeightRatio){
  std::string firstFrame,frameName,plist,plistPng;    
    
  plist=powerFileInfo.animFileInfo.plist;
    plistPng=powerFileInfo.animFileInfo.plistPng;
    firstFrame=powerFileInfo.animFileInfo.firstFrame;
    frameName=powerFileInfo.animFileInfo.frameName;
    // generic animation play code
    CCSpriteFrameCache *animCache = CCSpriteFrameCache::sharedSpriteFrameCache();
    animCache->addSpriteFramesWithFile(plist.c_str());
    
    _animPlayBatchNode = CCSpriteBatchNode::create(plistPng.c_str(), 100);
    this->addChild(_animPlayBatchNode,kForeground+1);

    short numberOfFrames=getPlistFramesCount(plist.c_str(),"frames");// plist is the full name with postfix .plist
    
    CCArray *spriteframes = CCArray::createWithCapacity(numberOfFrames);
    spriteframes->retain();
    
    _animPlayFirstSprite = CCSprite::createWithSpriteFrameName(firstFrame.c_str());// with postfix .png
    _animPlayBatchNode->addChild(_animPlayFirstSprite,kForeground+1);
    _animPlayFirstSprite->setPosition(ccp(_screenSize.width*placeAtScreenWidthRatio, _screenSize.height*placeAtScreenHeightRatio));
    
    for(int i = 1; i <= numberOfFrames; i++)
    {
        char szName[50] = {0};
        sprintf(szName, "%s%i.png",frameName.c_str(),i);
        CCSpriteFrame* frame = animCache->spriteFrameByName(szName);
        spriteframes->addObject(frame);
    }

    CCAnimation *animation = CCAnimation::createWithSpriteFrames(spriteframes,0.05f);
    animation->retain();
    animation->setDelayPerUnit(0.08f);// 0.05f
    
    CCSequence *seq=CCSequence::createWithTwoActions(CCAnimate::create(animation), CCCallFuncO::create(animation,callfuncO_selector(GameLayer::animationFinished),(CCObject*)_animPlayBatchNode));
    
    _animPlayFirstSprite->runAction(seq);
    
    spriteframes->release();
    animation->release();
    
}

void GameLayer::animationFinished(CCObject *sender){
    
CCSpriteBatchNode *animBatchNode = (CCSpriteBatchNode*) sender;
animBatchNode->removeAllChildrenWithCleanup(true);
_isAnimationAlreadyPlaying=false;

//   animBatchNode->removeFromParent() , crashes if I do this

}

sorry I am not able to correct the code format