You may withdraw or withhold life sustaining care if the person is terminally ill with almost no chance of recovery and totally dependent on artificial means to survive.
Medicine is a blessing from Allah and it is recommended for Muslims to utilize medicine whenever it is beneficial. The Prophet said, “Use medicine, because Allah has not created any illness without also creating its cure, except for one: old age.” [Source: xyz] However, for a terminally ill patient who is totally dependent on artificial means to survive, after expert medical opinion has determined that life sustaining medicine or treatment will only prolong the dying process but not help them recover, then it is not required to take such medicine or treatment. This is the case with disconnecting life support systems, respirators, or even feeding tubes.
Withholding or withdrawing treatment is entirely different than euthanasia, or “mercy killing”, which is forbidden in Islam. Refusing to feed a sick patient is a form of killing them through starvation if they can eat and drink on their own normally. However, if someone cannot eat or drink on their own and require machines to “feed” them, this is akin to administering medicine, and it is allowed to withhold medicine from a patient when it does not actually improve their condition but prolongs their suffering.
Shaykh Mustafa Umar