I would talk them out of it. There lives are important. I would do whatever I could to protect their life.
It is not good to kill yourself. The people in the world are important. This person could do something great. You never know, the person who knew how to cure cancer could have committed suicide, which is why cancer is still here. Every life matters. THEY NEED TO BE PRESERVED!
Personally, I have been there. I know how it feels, and the hopelessness of it all. My strategy wouldn't be to strait up try to convince them not to do it, but to just listen. Listen to anything they want to talk about, while keeping it oriented to them, not adding suggestions or ways of fixing things, the most beneficial thing I can do is to just listen. During this, I might add why the choice they may make is the wrong one, using arguments that are almost impossible to dismiss of refute, thinking carefully about what I am going to say, to avoid making things even worse.
Just being there, and understanding their stuggles is all I have the ability to do, goingg about trying to solve all their problems is harmful for they probably have already thought of your solution. Reason why their desition might be wrong, but do it right. This is what I would have needed when I was in situations like this.