The Prophet ﷺ used to observe retirement (i'tikaf) to the mosque during the last ten days of Ramadan till Allah took him, and then his wives observed retirement to the mosque after his death. (Using translation from Abū Dāʾūd 2462)
أَنَّ النَّبِيَّ ﷺ كَانَ «يَعْتَكِفُ الْعَشْرَ الْأَوَاخِرَ مِنْ رَمَضَانَ حَتَّى تَوَفَّاهُ اللهُ ثُمَّ اعْتَكَفَ أَزْوَاجُهُ مِنْ بَعْدِهِ»