Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
tabarani:18658al-Ḥusayn b. Isḥāq > Hawbar b. Muʿādh > Muḥammad b. Sulaymān > And Ḥshī from his father from his grandfather

[Machine] The Prophet ﷺ went out of his house at night to fulfill his need. He left the door of the house open and then returned to find Satan standing in the middle of the house. The Prophet ﷺ said, "Curse be upon you, O evil one, for entering my house." Then the Messenger of Allah ﷺ said, "When you go out of your houses at night, close the doors."  

الطبراني:١٨٦٥٨حَدَّثَنَا الْحُسَيْنُ بْنُ إِسْحَاقَ ثنا هَوْبَرُ بْنُ مُعَاذٍ ثنا مُحَمَّدُ بْنُ سُلَيْمَانَ ثنا وَحْشِيٌّ عَنْ أَبِيهِ عَنْ جَدِّهِ

أَنَّ النَّبِيَّ ﷺ خَرَجَ لِحَاجَتِهِ مِنَ اللَّيْلِ فَتَرَكَ بَابَ الْبَيْتِ مَفْتُوحًا ثُمَّ رَجَعَ فَوَجَدَ إِبْلِيسَ قَائِمًا فِي وَسَطِ الْبَيْتِ فَقَالَ النَّبِيُّ ﷺ «اخْسَأْ يَا خَبِيثُ مِنْ بَيْتِي» ثُمَّ قَالَ رَسُولُ اللهِ ﷺ «إِذَا خَرَجْتُمْ مِنْ بُيُوتِكُمْ بِاللَّيْلِ فَأَغْلِقُوا أَبْوَابِهَا»