I found that listing out all my options helpful in combatting feeling trapped or suicidal, and I would read over the list frequently. Some options may include sitting through your 3 final exams, leaving the program, or taking a break for a year or two. You could join a volunteer organization and travel. You could take a week off. You could find a job in another sector. You could spend time pursuing your hobbies or dream job. Be creative when you brainstorm what you could do. Once you have a list, it's easier to see alternatives, whether or not you decide to pursue them.
There are a number of activities that I tried over the course of several months to get myself back to decent mental state, including: meditation, long walks, reading, exercise, spending time with friends and family, opening up about my situation to friends and family, seeing a therapist, changing up routine, and volunteering. I encourage you to try a variety of activities, even if you don't initially feel like doing anything. For me, getting out of my apartment at least once a day was critical to turning myself around.