My uncle asked Messenger of Allah ﷺ about a person who imagined to have passed wind during the prayer. Allah' Apostle replied: "He should not leave his prayers unless he hears sound or smells something."
أَنَّهُ شَكَا إِلَى رَسُولِ اللَّهِ ﷺ الرَّجُلُ الَّذِي يُخَيَّلُ إِلَيْهِ أَنَّهُ يَجِدُ الشَّىْءَ فِي الصَّلاَةِ فَقَالَ لاَ يَنْفَتِلْ أَوْ لاَ يَنْصَرِفْ حَتَّى يَسْمَعَ صَوْتًا أَوْ يَجِدَ رِيحًا