Suicidal thoughts can be very distressing. They can be seen as indicators for seeking help. They basically signify that things / situation is overwhelming and one is not able to positively cope with things. They are sometimes considered to be a failure of positive coping strategies. Sometimes suicidal thoughts can indicate a sense of hopelessness arising out of depression, but do not always indicate originating from depression. It might be that you could be suffering from clinical depression.
If that is the case, it requires initially a comprehensive assessment and then the decision that is it just psychological treatment, which is going to be helpful or maybe medications. In your case, I would suggest develop and follow a few rules. Never act out on your suicidal thoughts. Seek out the assistance of a known person or professional or even a suicide help line. Develop positive coping strategies with the help of a psychologist and practice them. Consider visiting a psychiatrist as soon.