No one mentioned Batman.
With a “buttload” of farting experience, I can say with an “assload” of confidence that most farts are preventable at least until you can get to a “safe” area. However, this is not true across all farts. The OP should just consider situations like that an opportunity to practice breathing exclusively through the mouth.
Fart in an elevator
Foggin’ it up while I’m goin’ down…