handle optional onEscape handlers