Joint account with non-Muslim who allowed him to withdraw from the account, then retracted, then died
Question

I have a non-Muslim friend who opened a joint bank account with me and deposited money into it, saying, "Take whatever you want from it." After some time, he told me not to take from the account because he needed the money, then he passed away. Am I entitled to take the money in the account since the donor cannot retract a gift? And if I am not entitled, should I give the money to the deceased's brother, who is a non-believer, or should I give it in charity, knowing that legally I can take the money since the account is in both our names?
Praise be to Allah.Firstly:
The act of this person placing money in a joint account under both of your names and allowing you to take from it as you wish is a permissible donation, and there is no harm in accepting a gift from a non-believer.
What you withdrew from the account before his death, and before he prevented you from withdrawing from it, is a gift that has been received and the donor is not allowed to retract it; as narrated by Al-Bukhari (2589), and Muslim (1622) from Ibn `Abbas (may Allah be pleased with him) who said: The Prophet (peace and blessings be upon him) said: "The one who takes back his gift is like a dog that vomits and then eats its vomit."
And in another narration by Al-Bukhari (2622), "The bad example is not for us. He who takes back his gift is like a dog that swallows back its vomit."
Abu Dawud (3539), At-Tirmidhi (2132), An-Nasa'i (3690), and Ibn Majah (2377) narrated from Ibn `Umar and Ibn `Abbas about the Prophet (peace and blessings be upon him) who said: "It is not lawful for a man to give a gift or to grant a gift and then take it back, except for a father in what he gives to his child, and the example of the one who gives a gift and then takes it back is like a dog that eats until it is full, then vomits and eats its vomit." And the Hadith was authenticated by Al-Albani in "Sahih Abu Dawud."
As for what remains in the account, at most it is an uncollected gift, and it is permissible for him to retract it.
In "Al-Mawsu`ah Al-Fiqhiyyah" (6/164): "It is permissible to retract a gift before it is collected according to the majority, but once it is collected, there is no retraction according to the Shafi`i and Hanbali schools, except for what a father gives to his child. According to the Hanafi school, retraction is permissible if it is to a stranger.
As for the Maliki school, there is no retraction in their view for a gift before or after collection in general, except for what a father gives to his child." End quote.
And it is stated in "Kashshaf al-Qina`" (4/301): "The gift is binding (by its collection with the donor's permission), and (not) binding (before that), meaning: before the collection with the donor's permission." End quote.
Therefore; it is permissible for him to prevent you from taking anything from the account; because he initially permitted the withdrawal from it, then he retracted his permission and the money remains his property. And if we say: it is a gift, then it is a retraction of the gift before collection, which is permissible.
Secondly:
If the owner of the money dies, then his wealth belongs to his heirs who are of his religion, and it is not lawful for you to dispose of his wealth or to give it in charity, but rather you should hand it over to his cousin who is his heir; because it has become a trust in your hands, and you must deliver it to its rightful owner, even if he is a non-believer. Allah Almighty says (interpretation of the meaning): {Indeed, Allah commands you to render trusts to their owners} [An-Nisa' 4:58].
And Allah knows best.