Abu Dharr reported,

The Prophet ﷺ said to Abu Dharr when the sun had set, "Do you know where it goes?"I said, "Allah and His Messenger know best."He said, "It travels until it prostrates beneath the Throne, then seeks permission and is granted it. A time is near when it will prostrate but its prostration will not be accepted, and it will seek permission but will not be granted it. It will be told, 'Return to where you came from,' so it will rise from its place of setting. That is the meaning of His statement, 'And the sun runs to its appointed resting place. That is the decree of the Almighty, the All-Knowing' [Ya-Sin 36:38]."

Bukhari 3199

Sahih

حدثنا محمد بن يوسف حدثنا سفيان عن الأعمش عن إبراهيم التيمي عن أبيه

عن أبي ذر رضي الله عنه قال

قال النبي ﷺ لأبي ذر حين غربت الشمس أتدري أين تذهب قلت الله ورسوله أعلم قال فإنها تذهب حتى تسجد تحت العرش فتستأذن فيؤذن لها ويوشك أن تسجد فلا يقبل منها وتستأذن فلا يؤذن لها يقال لها ارجعي من حيث جئت فتطلع من مغربها فذلك قوله تعالى {والشمس تجري لمستقر لها ذلك تقدير العزيز العليم}

البخاري 3199صحيح
Contents
Reference
Commentary
Ayat
Collection
Sahih Bukhari
Book
Beginning of creation
Chapter
Characteristics of the sun and moon
Numbering
Darussalam 3199
Bukhari 3199