Never. Involuntary commitment is a giant fear of mine. I've been tempted in the past, but almost every therapist I've spoken to states they are legally required to take action the moment they learn from you that you intend to harm yourself, and/or others. I get the homicidal part, but with respect to the suicidal part, well...some of the horror stories I have seen, as well as what the numerous other people here sharing their experiences over how the psychiatric system only made things worse (possibly not true for everyone though), motivates me to keep silent about anything related to suicide, no matter how small. I regularly see a counselor, a psychiatrist, and a psychotherapist in managing my depression, anxiety, and past traumas. The therapy does help, but anytime they ask anything suicide-related, I always deny it. Last time my psychotherapist met with me, she was intentionally exploring to see if I was really suicidal. Got her to believe I wasn't, but I swear...any hint that they may detect you're suicidal, and you could be held against your will. Even choosing to say "I prefer not to answer" when they ask if you're suicidal is enough of a hint that they can detect you're suicidal. I said that once in college, and literally three professionals deduced I was, but it took a lot of legal talk, red tape, and convincing that I was well enough to leave without any involuntary commitment being enacted. I now always answer a fat solid NO whenever anyone asks anything suicide-related.
Important Note: If you truly feel you need emergency psychiatric care, then do what you feel is best. I get not all mental hospital stories are horrible, and for some people, it could supposedly be beneficial. I know my antidepressant has been helping me, as have my counseling sessions. If you need it, there is no shame in getting professional help. Sometimes the related therapies can be especially helpful in improving some parts of your life, and sometimes we all just need some external help to get better. That having been said, this is especially important for anyone wanting to go out by shooting themselves with a firearm. If you live in the U.S., regardless of state laws, at the federal level, anyone who has been involuntarily committed to a mental institution or is "adjudicated as a mental defective" can be banned from legal firearm ownership for life until the state/federal government grants you relief and determines you are no longer a danger to yourself or others, and determines through its own evaluations that you have been able to successfully reintegrate back into society. I don't know how the process goes exactly with restoring your firearm rights, but it can be quite hard, costly, and lots of legal yuck. Having a mental illness and/or getting treatment for it doesn't disqualify you from owning guns; it is only when you get involuntarily committed (like admitting to the therapist anything suicide-related) or if a judge mandates some kind of official court order that you would be classified as a "mental defective" (which a judge can easily do if you've admitted to being a suicide risk). I realize that term is kind of offensive, but it's the legal terminology used by the goverment. Voluntary commitment to a mental institution and/or being able to leave after a 72 hour initial psychiatric assessment from a proposed commitment won't take away your firearm rights.
I only say the above for anyone living in the U.S., and who may be considering suicide via firearm. If that is something you want to someday be able to do, or at least have it as an option, be very careful about opening up about anything suicide-related to therapists. It's the main reason I strongly avoid involuntary commitment at all costs, and why I always deny any form of suicidal ideation, no matter how small. See ATF Form 4473 Question 11.f to get all the legal specifics when it comes to how you could lose your firearm rights with respect to mental health, as well as all the other factors that could bar you from gun ownership via the other questions on that federal background check form.