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.
quran:110:3

Then exalt ˹Him˺ with praise of your Lord and ask forgiveness of Him. Indeed, He is ever Accepting of repentance.  

then glorify with praise of your Lord, that is, continuously praising Him, and seek forgiveness from Him; for verily He is ever ready to relent. The Prophet (s), after this sūra had been revealed, would frequently repeat the words subhāna’Llāhi wa bi-hamdihi, ‘Glory and praise be to God’, and astaghfiru’Llāha wa-atūbu ilayhi, ‘I seek forgiveness from God and I repent to Him’; with ˹the revelation of˺ this ˹final sūra˺ he realised that his end was near. The victory over Mecca was in Ramadān of year 8; the Prophet (s) passed away in Rabī‘ I of the year 10. Meccan, consisting of 5 verses. When the Prophet (s) summoned his people and said, ‘I am a warner to you, ˹standing˺ before a terrible chastisement’, his uncle, Abū Lahab, said, ‘May you perish! Is that what you have called us out for?’, whereupon the following was revealed:
القرآن:١١٠:٣

فَسَبِّحْ بِحَمْدِ رَبِّكَ وَاسْتَغْفِرْهُ ۚ إِنَّهُ كَانَ تَوَّابًا  

{فسبح بحمد ربك} أي متلبسا بحمده {واستغفره إنه كان توابا} وكان ﷺ بعد نزول هذه السورة يكثر من قول: سبحان الله وبحمده، أستغفر الله وأتوب إليه، وعلم بها أنه قد أقترب أجله وكان فتح مكة في رمضان سنة ثمان وتوفي ﷺ في ربيع الأول سنة عشر.