My thoughts with this was to give him a retry prior to being attacked, i.e. he bought more time by threatening the eggs to give himself another shot at the gate without taking damage. IME, once battle is engaged, it usually benefits the PC to just fight. Moving away and taking attacks of opportunity just don’t measure up to fighting the monster at that point, which I think is a bit of a problem with 5e.
In a way, the party actually benefits somewhat from the portcullis. The wizard is now safe on the other side and still can cast spells free from taking harm from the owlbears.