I'm glad it helped
I also find that when we do have to leave, if I do it in a punitive way she doesn't learn, but if I turn it into a positive thing it really benefits her. Children really can't help the way they feel and act so punishing them for it does nothing.
I really identify with positive parenting. If I sense that she is not coping with a group setting I will often call her on her behaviour as a warning, and if the behaviour continues I will let her know we are leaving so we can go for a walk to calm down, rather than because she has been naughty.
We will usually talk about why we left, and how she was feeling. Usually I get told that x was making her frustrated or she couldn't concentrate because y was too noisy, which at this point she recognises those feelings but doesn't know how to react to them, so she lashes out. I think it really helps to do this so that she can develop coping strategies to new feelings, and so she can understand that what she is feeling is normal and quite ok, but that there are better ways of reacting to them.