I like this question, because if I'm fully honest, I don't. I stay awake until 2AM - 4AM reviewing the day and taking a personal moral inventory. I compare this inventory to the week, then the year, finally my life.
I try to justify one action as a balance towards other actions and try to devise a plan of action for the next three days on how I can overcome the bad actions I've done. I know when I haven't fully internalized all my actions and developed justifications because they're usually what I begin to dream about after I fall asleep.
If my daily moral scale weighs negatively, I usually have bad dreams. If the moral scale weighs positively, I get good dreams. Like I've said, I'm not a fan of dreams anymore. They make me want to go back to take psychs where I can dream years upon years and enjoy making these moral justifications as means to "right" my wrongs.
Writing helps me in this process because it allows me to get the hefty thoughts out and leave enough room for the miniscule thoughts to battle each other into righteousness.
How do I sleep at night? I write.