Sayyiduna Abu Dharr (may Allah be pleased with him) narrates that the Noble Prophet (peace and blessings of Allah be upon him) said to Abu Dharr while the sun was setting: "Do you know where this (sun) goes?" I said, "Allah and His Messenger know best." He (peace be upon him) said: "It goes and prostrates under the Throne, then seeks permission (from Allah) to rise (from the east), so it is granted permission. And soon a time will come when it will prostrate, but its prostration will not be accepted, and it will seek permission but will not be granted permission. Rather, it will be told: 'Return from where you came.' So it will rise from the west. This is the meaning of Allah Almighty's statement: 'And the sun runs on its fixed course, that is the decree of the All-Mighty, the All-Knowing.' (Surah Ya-Sin: 38)."
Narrated by Abu Huraira (may Allah be pleased with him) from the Prophet (peace and blessings of Allah be upon him) that he said: On the Day of Resurrection, the sun and the moon will be folded up (they will lose their light).