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:16:70

And Allah created you; then He will take you in death. And among you is he who is reversed to the most decrepit ˹old˺ age so that he will not know, after ˹having had˺ knowledge, a thing. Indeed, Allah is Knowing and Competent.  

And God has created you, when you were nothing, then He takes you ˹in death˺, when your terms ˹of life˺ are concluded; and there are some among you who are relegated to the most abject stage of life, that is, the most diminished, because of old-age and senility, so that he knows nothing after ˹having possessed˺ some knowledge. ‘Ikrima said, ‘Whoever recites the Qur’ān will not come to such a predicament’. God is Knowing, of how to manage ˹the affairs of˺ His creation, Powerful, in ˹doing˺ what He will.
القرآن:١٦:٧٠

وَاللَّهُ خَلَقَكُمْ ثُمَّ يَتَوَفَّاكُمْ ۚ وَمِنْكُمْ مَنْ يُرَدُّ إِلَىٰ أَرْذَلِ الْعُمُرِ لِكَيْ لَا يَعْلَمَ بَعْدَ عِلْمٍ شَيْئًا ۚ إِنَّ اللَّهَ عَلِيمٌ قَدِيرٌ  

{والله خلقكم} ولم تكونوا شيئاً {ثم يتوفاكم} عند انقضاء آجالكم {ومنكم من يرد إلى أرذل العمر} أي أخسه من الهرم والخرف {لكي لا يعلم بعد علم شيئاً} قال عكرمة من قرأ القرآن لم يصر بهذه الحالة {إن الله عليم} بتدبير خلقه {قدير} على ما يريده.