Sunan Ibn Majah, Book 22, Hadith 2808 (In-Book)

It was narrated from Abu Hurairah that the Messenger of Allah said: “A man may do the deeds of the people of goodness for seventy years, then when he makes his will, he is unjust in his will, so he ends (his life) with evil deeds and enters Hell. And a man may do the people of evil for seventy years, then he is just in his will, so he ends (his life) with good deeds and enters Paradise.”Abu Hurairah said: “Recite, if you wish: “These are the limits (set by) Allah (STW) up to His saying: 'a disgraceful torment'”

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

sunnah.com