Praise be to Allah.
I put this question to our shaykh, ‘Abd ar-Rahmaan al-Barraak (may Allah preserve him) and he said:
Phrases such as those that the grandmother said – “Whatever you and your children have; don’t talk to me about it” and “Who told you to transfer the money?” are not clear enough to establish that this money now belongs to you and you can keep it, because these are the kinds of words that people say to show kindness when dealing with one another, and she did not state clearly that she was waiving the debt.
As for her telling you to give it in charity, in this situation she is not permitted to dispose of her wealth, and in principle her wealth is now the right of her heirs, so it cannot be taken away from them except on the basis of certainty, and there is no certainty in this case, because she was sick and was drifting in and out of consciousness. Based on that, you should inform the heirs of exactly what she said about giving the rest of the money owed in charity, then if they consent to that, you should give it in charity on her behalf, otherwise the money should be given back to the heirs and divided along with the rest of the estate.
And Allah knows best.