Although many people are told that its best to pull the plug on paitents that are brain dead, there are cases in which people have survived, such as this one.
If it is possible for someone to recover from brain death that must mean that the human soul is still in the body while they are being pronounced as "leagally dead."
death is usually defined as the end of life for a living creature.
“Allah takes soul at the time of their death and [the souls] of those that do not die during their sleep. He retains those souls for which He has ordained death, whereas He releases the rest for an appointed term.39:42”
If one soul is still in their body, their life must not have ceased, because a soul only returns to the body at the day of ressurection. So in that case, when you pull the plug and their heart stops beating and their soul leaves their body, they would die at that instance not when they are prounouced as leagly dead.
Allah says that he has determined a time for us to die, and even if you hide you will die at that moment.
Then after distress, He sent down upon you security [in the form of] drowsiness, overcoming a faction of you, while another faction worried about themselves, thinking of Allah other than the truth - the thought of ignorance, saying, "Is there anything for us [to have done] in this matter?" Say, "Indeed, the matter belongs completely to Allah ." They conceal within themselves what they will not reveal to you. They say, "If there was anything we could have done in the matter, some of us would not have been killed right here." Say, "Even if you had been inside your houses, those decreed to be killed would have come out to their death beds." [It was] so that Allah might test what is in your breasts and purify what is in your hearts. And Allah is Knowing of that within the breasts.3:135
the example in the Quran above is much like the situation of brain death, the people believe that they had no chance at survival and that nothing could have been done. But Allah reasurred them that no matter what, they would die at the instance that he planned for them.
If a person is still alive, even if it be with a respitory machine, it must mean that it isnt their time to die yet. Allah has still allowed them to live. By pulling the plug, you are interfearing with Allah's plans for that human. If it were really the time to let that person go, then Allah would do so, not us.
in the same verse above, Allah says that it is a test for us that he has determined our time of death, and we must give our trust to allah. When we pull the plug, we are not givng our trust to allah and determining for ourselves that it is better for them to die.
So in conclusion, we should trust allah for our time of death if it were best that we die at that moment then we will by the decree of allah. By pulling the plug we are interfearing with our qadr. If there is a possibilty of a brain dead person to recover, than that means that the soul is still in their body. By pulling the plug, we are killing that human.