Assalamo alikom
Well, I have heard of people who came out of long coma. So, I think people who are responsible for the person in coma should wait to be sure that their patient's chances for coming back is no longer there. I think doctors can determine that. If doctors said that the patient will not come out of it and will always depend on machines to keep breathing, then it would never be considered killing to stop those machines.
As for when a person is afflicted by harm and think to end his life because he can no longer bear it. The prophet peace be upon him said:
(198) Narrated Anas: Allah's Apostle said," None of you should long for death because of a calamity that had befallen him, and if he cannot, but long for death, then he should say, 'O Allah! Let me live as long as life is better for me, and take my life if death is better for me.' " (Book #75, Hadith #362)