Fairly sure it's illegal in parts of the states, at least. Certainly you can be institutionalized et al for attempting it. Not sure if or to the extent there's actual criminal laws, but yeah. Actual suicide isn't, s'far as I'm aware, but attempted suicide is (in some places), iirc. Or something very similar to illegal, anyway. E: Wiki has
this to say. Looks like it's improved, somewhat, since the last time my attention noticed it. E2: But do notice that last bit re: being committed for evaluation and treatment.
As for the first bit, the problem is with the "thinking rationally" part. There's those that hold that
any action that seeks death is irrational, and thus anyone that would choose death over life, regardless as to the quality of that life, is not capable of thinking rationally -- and thus can have their autonomy overruled. I'm not entirely sure how much that line of thinking is legally enshrined these days, but I'm fairly certain it's been used before. Who decides what construes rational thought, and who is capable of it?
I'd be incredibly dubious that anyone making that claim has actually
experienced something like chronic, crippling pain, or even "merely" extended and intense suffering, though. People who claim there's no fate worse than death rarely seem to have. Gods know if I had to live with something like kidney stone pain on a daily basis, I'd tear my own damn throat out. Couple weeks of that under fairly heavy painkillers was bad enough.