The words of a Muslim, {رَبِّ أَوْزِعْنِىٓ أَنْ أَشْكُرَ نِعْمَتَك} “My Lord, enable me to be grateful for Your Favor...” (AN-Naml 19) is not restricted to them reaching the age of 40

Every monotheist should say often,

{رَبِّ أَوْزِعْنِىٓ أَنْ أَشْكُرَ نِعْمَتَكَ ٱلَّتِىٓ أَنْعَمْتَ عَلَىَّ وَعَلَىٰ وَٰلِدَىَّ وَأَنْ أَعْمَلَ صَـٰلِحًۭا تَرْضَىٰه}
My Lord, enable me to be grateful for Your Favor which You have bestowed upon me and upon my parents and to do righteousness of which You approve...” (AN-Naml 19),

that is, inspire me and make me adhere to being grateful for your favors. This supplication has been stated in Soorah Al-Ahqaaf restricted to reaching 40 years of age, as Allaah  said,

{حَتَّىٰٓ إِذَا بَلَغَ أَشُدَّهُۥ وَبَلَغَ أَرْبَعِينَ سَنَةًۭ قَالَ رَبِّ أَوْزِعْنِى}
[He grows] until, when he reaches maturity and reaches [the age of] forty years, he says, "My Lord, enable me...” (Al-Ahqaaf 15)

until the end of the aayah. Indeed, such matters, even if connected to a specific reason, they are not restricted to that particular cause. Hence, this Remembrance of Allaah can be said by both young and old, and those who have reached 40, and those below or above it.