´It was narrated that Abu Musa said:` "A house burned down in Al-Madinah, with its occupants inside. The Prophet(ﷺ) was told of what had happened, and he said: 'This fire is an enemy to you. When you go to sleep, extinguish it.'"
Hadith Referenceسنن ابن ماجه / كتاب الأدب / 3770
Hadith Gradingالألبانی:صحيح | زبیر علی زئی:متفق عليه
Narrated Abu Musa: One night a house in Medina was burnt with its occupants. The Prophet spoke about them, saying, "This fire is indeed your enemy, so whenever you go to bed, put it out to protect yourselves."
Shaykh Abdul Sattar al-Hammad
Hadith Commentary: (1) In this hadith, the wisdom behind extinguishing the fire before sleeping is explained: there is a risk of burning from it. This applies to any fire, whether it is a lamp or a stove. In addition, the same ruling applies to gas heaters and electric bulbs. (2) Fire has been described as an enemy because there is always a risk of harm to life and property from it, just as there is danger from an enemy, even though it also has countless benefits. (Fath al-Bari: 11/103)
Source: Hidayat al-Qari: Commentary on Sahih Bukhari, Urdu, Page: 6294