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:79:25

So Allah seized him in exemplary punishment for the last and the first ˹transgression˺.  

So God seized him, He destroyed him by drowning him, as punishment for the latter, that is to say, these ˹last˺ words ˹of his˺, and for the former, that is to say, his saying previously, ‘I do not know of any god for you other than me’ ˹Q. 28:38˺ — and between the two ˹claims made by Pharaoh˺ was an interval of forty years.
القرآن:٧٩:٢٥

فَأَخَذَهُ اللَّهُ نَكَالَ الْآخِرَةِ وَالْأُولَىٰ  

(فأخذه الله) أهلكه بالغرق (نكال) عقوبة (الآخرة) أي هذه الكلمة (والأولى) أي قوله قبلها: "" ما علمت لكم من إله غيري "" وكان بينهما أربعون سنة.