Hadithcore
Mishkat al-Masabih, 1521

Ibn ‘Umar told that when the Prophet (ﷺ) heard the sound of thunder and of thunderbolts he said, "O God, do not kill us with Your anger and do not destroy us with Your punishment, but preserve us before that happens." Ahmad and Tirmidhi transmitted it, the latter saying that this is a <i>gharib</i> tradition.

وَعَنِ ابْنِ عُمَرَ أَنَّ النَّبِيَّ صَلَّى اللَّهُ عَلَيْهِ وَسَلَّمَ: كَانَ إِذَا سَمِعَ صَوْتَ الرَّعْدِ وَالصَّوَاعِقَ قَالَ: «اللَّهُمَّ لَا تَقْتُلْنَا بِغَضَبِكَ وَلَا تُهْلِكْنَا بِعَذَابِكَ وَعَافِنَا قَبْلَ ذَلِكَ» . رَوَاهُ أَحْمَدُ وَالتِّرْمِذِيُّ وَقَالَ: هَذَا حَدِيثٌ غَرِيبٌ

References1 variant
In-Book Reference
Book 4, Hadith 920