Whoever Breaks Wind during Prayer, should Leave the Prayer
Question :
A person entered the first row of worshippers, then he broke wind, but he remained in prayer, in order to avoid cutting the row and being forced to pass between the rows of worshippers behind him, annoying them and disturbing their tranquility. What is the ruling on this?
Answer:
We hope that Allah will forgive him. It is an obligation upon a person who breaks wind while in prayer, or remembers that he is not in a state of ritual purity, to leave the prayer and go and make ablution, then return and pray what he catches of the congregational prayer. As for the rows of worshippers, the Sutrah L of the Imam is their Sutrah.So if he passes in front of those being led in prayer, there is no objection to that; but he must leave the row calmly and quietly, so that he does not annoy the other worshippers.
Source:
Ibn Jibreen
Fatawa Islamiyah, Vol. 2 Page 38