grandalf's comment is inaccurate, but it's also a sort of understatement to say that mental illness "is a factor in some attempted suicides or completed suicides". It's by far the biggest factor.
> More than 90 percent of people who die by suicide have [depression and other mental disorders, or a substance-abuse disorder (often in combination with other mental disorders)]
Exactly, I didn't mean to generalize to claim that mental illness is the only cause, but I would say that mental illness is the common thread in 99%+ of suicides.