Sometimes it so happens that you are alone or at work, could be both, and thinking about relatively something else not directly related to your work or to yourself. Any problem that has been the cause of some concern or any past occurrences that were not at all pleasant for you.
Some solutions to counter this situation could be to take some time off. Go to a relaxing place where you feel comfortable. Call a friend who can help you counter these thoughts. Just start thinking about positive things. Believe in yourself that you can handle all your problems even though they look really hard. Just stop worrying.
Because the reality is, that life isn't perfect. We keep on hoping that there will be a time when all the worries will be gone and everything is going to be alright, it's just a myth. That is not the reality. There are always going to be some challenges, which is what makes our lives more interesting, but, trust me, you will always find ways to conquer all challenges, don't give up. Hang in there and keep trying.