CCLayer, cannot self-remove

Hello. I’m adding new CCLayer to current scene and want to remove in by pressing back key.
Layer1:

dialog = DialogLayer::create();
CCDirector::sharedDirector()->getRunningScene()->addChild(dialog, 1, 100);
DialogLayer:
void DialogLayer::keyBackClicked()
{
LOGD (“i am here”);
CCDirector::sharedDirector()->getRunningScene()>removeChildByTag;
}
But whei I’m pressing back key, layer is not removing.
Variant below doesn’t work too:
this
>getParent()->removeChildByTag(100,true);
Why? Is there way to self-remove CCLayer?

Keep a refrence to it and try calling removeFromParent on it.
Maybe that will work.

replace this:

@ this->getParent()->removeChildByTag(100,true);@

with this:

this->removeFromParentAndCleanup(true);