In the last chapter of 1 Samuel, we find King Saul surrounded by his enemies, and rather than risk being captured and tortured, he asks his assistant to run him through with a sword. The assistant refuses, so King Saul falls on his own sword.
In the next chapter, the first chapter of 2 Samuel, we find that a third party, an Amalekite, claims to the future King David to have come upon King Saul, who was not yet dead but beyond recovery. He further claimed that at Saul's request, he finished the dying king off.
David soon thereafter had this Amalekite executed. Staying in context, the reason for the execution is that the Amalekite lifted his hand against one who had been anointed by God. But if we take a little bit of liberty with the text, it's not hard to apply this to the idea of euthanasia, mercy-killing, in general.
It may be "merciful" to put a terminal patient out of his misery; after all, he's going to die anyway; why make him suffer any longer than necessary? But in Saul's case, the "mercy-killing" of an almost dead man was considered worse than letting that almost-dead man die on God's time-frame.
Don't think I'm offering any answers, or even any wisdom, here. I'm just reporting the story, and wondering how, if at all, it might apply to our modern tendency to pull the plug on hopeless cases.