Hadithcore
Mishkat al-Masabih, 2106

She said that the <i>sunna</i> for one who is observing a period of private devotion in a mosque is not to visit an invalid, or attend a funeral, or touch or embrace one’s wife, or go out for anything but necessary purposes. There is no period of private devotion in a mosque without fasting, and it must be carried out in a congregational mosque. Abu Dawud transmitted it.

وَعَن عَائِشَة رَضِي الله عَنْهَا قَالَتْ: السُّنَّةُ عَلَى الْمُعْتَكِفِ أَنْ لَا يَعُودَ مَرِيضًا وَلَا يَشْهَدُ جِنَازَةً وَلَا يَمَسُّ الْمَرْأَةَ وَلَا يُبَاشِرُهَا وَلَا يَخْرُجُ لِحَاجَةٍ إِلَّا لِمَا لابد مِنْهُ وَلَا اعْتِكَافَ إِلَّا بِصَوْمٍ وَلَا اعْتِكَافَ إِلَّا فِي مَسْجِدٍ جَامِعٍ. رَوَاهُ أَبُو دَاوُدَ

References1 variant
In-Book Reference
Book 7, Hadith 146