That's not a loophole, that's literally just a description of doing things how you're supposed to do them.
It's like describing rightlyfully claiming simple tax deductions you're entitled to as a "tax loophole" or winning a game by scoring the most goals against the other team as using the "goals loophole".
Read more than the first word of my post.
There are many other horrible, distressing and unpleasant things in life and not all of them involve pain. Pain is just a simple case.
Pain is just another form of distress, people with only a childlike understand of ethics might ignore anything except pain but relieving other forms of significant suffering can also perfectly ethically involve death. There are things in life worse than death and that doesn't just include pain.
Having literally everything you are slowly erased can be massively distressing to people.
Having literally everything you are slowly erased can be massively distressing to people.
And by your own reasoning, doctors are not allowed to kill them, because they're only allowed to kill people in pain and only by using physically damaging painkillers.
Over at Scott Adams' Blog you can find a very fine example of using the 'Rationality Engine' to solve the social problem of assisted dying.