The best solution is for a person to take a moment to relieve the gas in a bathroom or away from other people.
Obviously, there are various illnesses and food allergies that can cause flatulence.
Farting may be socially unacceptable in some places, but it is a natural bodily function.