How can a person stop thinking about being depressed and thinking of suicide?

Get treatment. Getting effective treatment for depression can help with thoughts of depression and suicide. Psychiatrists, psychologists, and other mental health practitioners can be good starting points. If your suicidal thinking includes making plans or you can't guarantee your safety as an outpatient, you need emergency evaluation. Talk therapy is very useful, and medications as needed. There is hope.
Seek help. If a person feels suicidal, he or she should seek help immediately by going right away to the nearest emergency department. There are all sorts of available treatments. The key is: do not wait..!