If I was in a painful state from which there was no return, I wouldn't leave it to my dog to take care of me...
Kidding, but their have been times when my family has had to put down our dogs. One was when it killed the neighbours cat in cold blood. It was my father's dog, and he was one ugly mutt. My pops loved him but he took him behind the shed and double tapped him. We all liked him but he was quite the bastard.
Another one, Jack, was kicked by our horse and he was in serious pain for a little time before we called the vet to euthanize him. And our 13 year old German Shepard was quite senile and my brothers took her down to the field late one night and... well one in the head one in the heart. One night she was there, yapping at every sound, the next silence.
It's a unique situation depending on dog and owner. Sometimes it is nice to be there for them when they go, sometimes it's just necessary and easier for everyone. I don't think I could take knowing when my Shepard was gonna go, and I hate the method they used and finding out about it, but I was glad it happened the way it did and that she was peaceful now.