Reference for Shabbat 2:5
הַמְכַבֶּה אֶת הַנֵּר מִפְּנֵי שֶׁהוּא מִתְיָרֵא מִפְּנֵי גוֹיִם, מִפְּנֵי לִסְטִים, מִפְּנֵי רוּחַ רָעָה, וְאִם בִּשְׁבִיל הַחוֹלֶה שֶׁיִּישַׁן, פָּטוּר. כְּחָס עַל הַנֵּר, כְּחָס עַל הַשֶּׁמֶן, כְּחָס עַל הַפְּתִילָה, חַיָּב. וְרַבִּי יוֹסֵי פּוֹטֵר בְּכֻלָּן חוּץ מִן הַפְּתִילָה, מִפְּנֵי שֶׁהוּא עוֹשָׂהּ פֶּחָם:
If one puts out the lamp because he fears idolators, [such as the Persians, who do not allow the lighting of a fire on their holidays outside their temples], robbers, [so that they not be aware of his presence and attack him], because of an evil spirit [resting upon him — not seeing, giving him relief (Rambam explains: "an evil spirit" — a kind of sickness to which those suffering from melancholia are prone. They find relief from it only by sitting in the dark, hidden from men)], or so that a sick man may sleep, he is exempt. [This "sick man" is one whose life is in danger; for if he puts it out for a sick man whose life is not in danger, he is liable, this tanna holding that one is liable for a labor not required for its own sake. Likewise, for fear of idolators, robbers, and an evil spirit — all, where life is in danger. And, by right, it should have been stated "permitted" (rather than "exempt"), but because it was to be taught "liable" at the end, it is taught "exempt" in the beginning.] (If he puts it out) in regard for the lamp, in regard for the oil, in regard for the wick, he is liable. [And even though the extinguishing is not needed in and of itself, but for the sake of something else — that the wick not burn or that the lamp not split — he is liable, one being liable for a labor that is not needed for its own sake.] R. Yossi exempts in all instances, except (when he puts it out in regard) for the wick, because he thereby chars it. [There is no extinguishing which is needed for its own sake but the extinguishing of charcoals and that of charring the wick, whereby it "takes" more readily when he lights it again. The halachah is not in accordance with R. Yossi. ("because he thereby chars it":) He intends charring it so that it burn better subsequently.]