(158) باب مَنْ صَلَّى بِالنَّاسِ فَذَكَرَ حَاجَةً فَتَخَطَّاهُمْ
Narrated `Uqba:
I offered the `Asr prayer behind the Prophet (ﷺ) at Medina. When he had finished the prayer with Taslim, he got up hurriedly and went out by crossing the rows of the people to one of the dwellings of his wives. The people got scared at his speed . The Prophet (ﷺ) came back and found the people surprised at his haste and said to them, "I remembered a piece of gold Lying in my house and I did not like it to divert my attention from Allah's worship, so I have ordered it to be distributed (in charity).
Reference: Sahih al-Bukhari 851
In-book reference: Book 10, Hadith 242
USC-MSA web (English) reference(deprecated numbering scheme): Vol. 1, Book 12, Hadith 810