What to say if you are afraid to go to sleep or feel lonely and depressed

‘A’oothu bikalimaatil-laahit-taammaati min ghadhabihi wa ‘iqaabihi, wa sharri ‘ibaadihi, wa min hamazaatish-shayaateeni wa ‘an yahdhuroon.

I seek refuge in the Perfect Words of Allah from His anger and His punishment, from the evil of His slaves and from the taunts of devils and from their presence.

Reference: Abu Dawud 4/12. See also Al-Albani, Sahih At- Tirmithi 3/171