How can I recover from a negative trigger?

Last night, I was out with my husband and friends, and something (which briefly seemed like a circumstance, but I have enough awareness now to quickly realise it was a thought) triggered some negative feelings in me (unworthiness, resentment). I really didn’t want those emotions to affect the evening, and when my husband noticed I wasn’t being myself, I told him I would be fine. I really wanted to find a thought that would help me put those emotions away and enjoy the rest of the evening out. But, I couldn’t quite shake it the whole night, there was an underlying negativity in me that I was trying to hold in. My husband later said that it came out in little ways of me being critical, and I know that wasn’t fair to him. We rarely go out on evenings like this, and I feel so rubbish that my emotions soured the night in a way. I really wish I’d been able to let the thing that triggered me go (or at least to deal with it later), to find a better thought, to fully enjoy the night and engage with our friends and to be loving and fun.
My question is, when this happens again, how can I recover from a negative trigger quickly and in the moment?