Up until I was about 26, I couldn't sleep because every night I would lay in bed and go over every single thing that had went wrong over and over. Not just things I had done but the bullying I encountered as a kid and a teen. Even all those years later I would go over and over everything until I was going crazy.
Sometimes when bad things happen I just obsess over them and can't stop. It's very difficult. I have to get to a place where I feel "safe." Sometimes that's really easy. One trick for me is sometimes I talk to my husband. He tends to be very logical about things. Sometimes just having that conversation of "this isn't a problem because...." will make it stop. When he's not available it takes all of my coping skills just to get through the day.