How can I escape this trap I'm trapped in?

My mind is constantly occupied with past traumas, and sometimes I find myself becoming an extremely pessimistic, melancholic, or dark-minded person. No matter what I try, at the end of the day, I find myself alone with my loneliness, surrendering to it, unable to think about anything other than death.

Yet, even during my difficult childhood, I used to be a very cheerful, happy, and energetic child.

How can I escape this trap I'm trapped in?
Post Opinion