Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
bayhaqi:3387Abū ʿAbdullāh al-Ḥāfiẓ And ʾAbū Saʿīd b. Abū ʿAmr > Abū al-ʿAbbās Muḥammad b. Yaʿqūb > Muḥammad b. ʿAlī > ʿAbdullāh b. Rajāʾ > Isrāʾīl > Yazīd b. Saʿīd from his father > ʿAlī > Man

[Machine] Whoever finds rice or urine in their stomach should cover their nose with their clothing, then move away and perform ablution. They should not speak to anyone, and if they do speak, they should start over. In all of this, if it is correct, it indicates that it is permissible to leave with the rice before the invalidation of prayer, and then the building on what has passed from the prayer. It was also narrated something similar to this from Salman al-Farsi.  

البيهقي:٣٣٨٧أَخْبَرَنَا أَبُو عَبْدِ اللهِ الْحَافِظُ وَأَبُو سَعِيدِ بْنُ أَبِي عَمْرٍو قَالَا ثنا أَبُو الْعَبَّاسِ مُحَمَّدُ بْنُ يَعْقُوبَ ثنا مُحَمَّدُ بْنُ عَلِيٍّ ثنا عَبْدُ اللهِ بْنُ رَجَاءٍ ثنا إِسْرَائِيلُ ثنا يَزِيدُ بْنُ سَعِيدٍ عَنْ أَبِيهِ عَنْ عَلِيٍّ ؓ قَالَ

مَنْ وَجَدَ فِي بَطْنِهِ رِزًّا أَوْ كَانَ فِي بَطْنِهِ بَوْلٌ فَلْيَجْعَلْ ثَوْبَهُ عَلَى أَنْفِهِ ثُمَّ لِيَنْتَقِلْ وَلْيَتَوَضَّأْ وَلَا يُكَلِّمْ أَحَدًا فَإِنْ تَكَلَّمَ اسْتَأْنَفَ وَفِي كُلِّ هَذَا إِنْ صَحَّ دَلَالَةٌ عَلَى جَوَازِالِانْصِرَافِ بِالرِّزِّ قَبْلَ خُرُوجِ الْحَدَثِ ثُمَّ الْبِنَاءُ عَلَى مَا مَضَى مِنَ الصَّلَاةِ وَرُوِيَ مِثْلُ ذَلِكَ أَيْضًا عَنْ سَلْمَانَ الْفَارِسِيِّ ؓ