All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad, sallallaahu ‘alayhi wa sallam, is His Slave and Messenger.
One is blameless for releasing wind when he is alone for two reasons:
First: withholding it is harmful to one's body.
Second: according to some scholars, prayer is disliked when one wants to release wind but he withholds it. Al-Mardaawi a Hanbali scholar, said: "It is disliked for one to perform the prayer while he withholds wind, according to the sound opinion of the Hanbali scholars."
Releasing wind invalidates Wudhoo’ and one has to perform a new Wudhoo’ for acts of worship which necessitate it, such as the prayer. The Prophet, sallallaahu ‘alayhi wa sallam, said: "Allaah Does not Accept the prayer of any of you, when he is in a state of impurity, until he performs Wudhoo’." [Al-Bukhari and Muslim. This is the wording of Al-Bukhari]
It is also narrated that the Prophet, sallallaahu ‘alayhi wa sallam, said: "If one of you finds a disturbance in his abdomen and is not certain if he released any wind or not, he should not quit his prayer unless he hears its sound or smells its odor (so as to be certain)." [Al-Bukhari and Muslim]
As for the question about whether what harms people harms the angels as well, the following are the Hadeeths that were narrated in this respect:
• The Prophet, sallallaahu ‘alayhi wa sallam, said: "Whoever eats onions, garlic or leeks, let him not come near our Masjid (prayer), for the angels are harmed by the same things that harm the sons of Adam." [Muslim]
• ‘Ali said: "The Messenger of Allaah, sallallaahu ‘alayhi wa sallam, commanded us to eat garlic. He said, 'Had it not been for the angel of revelation, I would have eaten it.'" [Al-Bazzaar and At-Tabaraani]
In Sharh Ma‘aani Al-’Aathaar, At-Tahaawi mentioned the Hadeeth and said: "It stands as evidence that eating garlic, whether it is cooked or not, is permissible for one who is in his home. Nevertheless, it is disliked that he attends the Masjid (place of prayer) while the smell is still there in order not to harm the angels and people. This is the opinion we adopt. It is also the opinion of Abu Haneefah, Abu Yoosuf and Muhammad ."