The eclipse prayer is missed if one of two things occurs:
1- If one is certain that the whole of the sun's disk has re-appeared. Jaber (G. p. H) narrated that the Prophet (P. B. U. H) said:
"If you see (a solar eclipse), then pray till it re-appears".
[Muslim, Vol. 2, The Book of Eclipse, Chapter 3/10]. (pa: 201)
Hence if part of the sun's disk re-appears and the other part remains hidden, the eclipse prayer is not missed.
Similarly, if one is not certain that the sun has re-appeared (Such as the case when there are thick clouds), then one can pray.
If the sun re-appears while praying, one should complete his prayer.
2- If the sun sets while in eclipse.
Hence, one is not permitted to commence prayer if it is sunset time. However, if one is in prayer and the sun sets while in eclipse, he should complete his prayer.
The lunar eclipse prayer is missed if one is certain that all of the moon has reappeared, or if the sun rises.
However, if dawn breaks or the moon sets while in eclipse, the prayer is not missed.
It is recommended to pray two rak'as when fearing earthquakes, thunderstorms and the like.
However, it is not recommended to pray them in congregation because such things occurred at the time of the Prophet (P. B. U. H) and it was not reported that he prayed any of them in congregation, except the eclipse prayer.