well, you cant really avoid it.
avoiding depressive episodes or thoughts can lead to the problem getting bigger and bigger, until eventually it bursts like a negative bubble.
what you can do, however, is: whenever you get suicidal or depressed, think of the people that care about you. think about what you care about. Another good thing to do is to think about what caused you to feel this sad, and if its that big of a deal. As humans, we like to make bigger deals out of everything and its, well, hard not to. But optimism is always key.
For example, you start feeling sad because someone yelled at you. Think about what they were actually yelling at you for, and what they were saying, instead of honing in on the fact that they were yelling at you.
and this isnt me trying to make it seem as if your feelings dont matter and "its not that big of a deal" because it is. it really is. Depression can drive people.. well, insane. All we can do is try to get help, and try to look on the positive side of life.