I used to own a gun, and after I had my first bout of depression severe enough to become more actively suicidal rather than have passive suicidal ideation and I checked myself in, I found a coworker who had many and was well-versed in their use to care for it and try to break it in a little more -- at that point I'd only put about 300 rounds through it at practice, was only able to practice once a month and generally only did 50 rounds each time (I practiced with snap caps with a proper backstop at home to try to catch my flinch, but really needed the alternating snap caps and real ammo to clear up the flinch -- probably should have started with a .22 but could only afford one firearm).
I'd had two other coworkers offer to take it, but both had voiced they'd been suicidal in the past and weren't current firearm owners. No way was I about to let them care for it, even though they were offering to help me, they said. When I moved back home, it got left at my sisters, and she eventually bought it from me.
Also, when I went out of town for a month while I had it, I "boarded" my gun at the pawn shop for $25 -- $100 pawn that I kept and paid back, and the $25 interest. I didn't want anyone to get into my house and steal it. It's a gun-owner's job to keep their gun from criminals, children, and the clueless. While I hate to put friends who have expressed suicidal ideation into the latter categories, it's more like a child -- if I know someone's thought of doing themselves in, I'm not about to give them (especially a male, who are far more prone to use guns) the way to do that if they have thoughts too. Just as I wouldn't leave it for a criminal to steal.
I don't think everyone who's ever been depressed should be barred from owning a gun. But involuntary commitment for suicidal thoughts involving firearms, rightly in my state, is a disqualification to purchase.