The Prophet ﷺ came rushing out to the masjid one day when the sun eclipsed, and he prayed until the eclipse ended, then he said: "The people of Jahilliyyah used to say that eclipses of the sun and the moon only happened when some great man on earth died. But eclipses of the sun and the moon do not happen for the death or birth of anyone. Rather they are two of the creations of Allah (SWT) and Allah (SWT) causes to happen in His creation what He wills. Whichever of them becomes eclipsed, pray until it is over or Allah (SWT) causes something to happen." (Using translation from Nasāʾī 1490)
عَنِ النَّبِيِّ ﷺ أَنَّهُ خَرَجَ يَوْمًا مُسْتَعْجِلًا إِلَى الْمَسْجِدِ وَقَدِ انْخَسَفَتِ الشَّمْسُ فَصَلَّى حَتَّى انْجَلَتْ ثُمَّ قَالَ إنَّ أَهْلَ الْجَاهِلِيَّةِ كَانُوا يَقُولُونَ إِنَّ الشَّمْسَ وَالْقَمَرَ لَا يَنْخَسِفَانِ إِلَّا لِمَوْتِ عَظِيمٍ مِنْ عُظَمَاءِ أَهْلِ الْأَرْضِ وَإِنَّ الشَّمْسَ وَالْقَمَرَ لَا يَنْخَسِفَانِ لِمَوْتِ أَحَدٍ وَلَا لِحَيَاتِهِ وَلَكِنَّهُمَا خَلِيقَتَانِ مِنْ خَلْقِهِ يُحْدِثُ اللهُ فِي خَلْقِهِ مَا شَاءَ وَأَيُّهُمَا انْخَسَفَ فَصَلُّوا حَتَّى يَنْجَلِيَ أَوْ يُحْدِثَ اللهُ أَمْرًا