The Messenger of Allah ﷺ said, "Each of you remains in prayer as long as the prayer keeps him waiting, with nothing preventing him from returning to his family except the prayer."
حدثنا القعنبي عن مالك عن أبي الزناد عن الأعرج
أن رسول الله ﷺ قال لا يزال أحدكم في صلاة ما كانت الصلاة تحبسه لا يمنعه أن ينقلب إلى أهله إلا الصلاة
Bukhari transmitted it in the Book of Adhan, Chapter on one who sits in the masjid awaiting the prayer and the merit of masjids, hadith no. 659, and Muslim in the Book of Masjids, Chapter on the merit of the prescribed prayer in congregation and the merit of waiting, etc., hadith no. 275/649, after hadith no. 661, from the hadith of Malik through this same chain. It is also found in the Muwatta (Yahya's recension), Book of Prayer, 1/160 (and Qanabi's recension, p. 106).