Sunan an-Nasa'i, Volume 3, Book 21, Hadith 1943 (DarusSalam)

It was narrated that 'Abdullah bin Al-Mughaffal said: "The Messenger of Allah said: 'Whoever follows a Janazah until it is finished, he will have two Qirats, and whoever goes back before it is finished, he will have one Qirat."

أَخْبَرَنَا مُحَمَّدُ بْنُ عَبْدِ الأَعْلَى، قَالَ حَدَّثَنَا خَالِدٌ، قَالَ حَدَّثَنَا أَشْعَثُ، عَنِ الْحَسَنِ، عَنْ عَبْدِ اللَّهِ بْنِ الْمُغَفَّلِ، قَالَ قَالَ رَسُولُ اللَّهِ صلى الله عليه وسلم ‏ "‏ مَنْ تَبِعَ جَنَازَةً حَتَّى يُفْرَغَ مِنْهَا فَلَهُ قِيرَاطَانِ فَإِنْ رَجَعَ قَبْلَ أَنْ يُفْرَغَ مِنْهَا فَلَهُ قِيرَاطٌ ‏" ‏ ‏.‏

sunnah.com