The Talmud says:
"הַמְכַבֶּה אֶת הַנֵּר מִפְּנֵי שֶׁהוּא מִתְיָרֵא מִפְּנֵי גּוֹיִם וּמִפְּנֵי לִיסְטִים, מִפְּנֵי רוּחַ רָעָה, מִפְּנֵי הַחוֹלֶה שֶׁיִּישַׁן — פָּטוּר."
"One who extinguishes a lamp on Shabbat because he is afraid... of an evil spirit, [Sefaria: i.e., he is depressed and prefers sitting in the dark] is not liable". [Shabbat 29b]
Is this leniency fleshed out a bit anywhere?