Repenting from having stolen property can only be done by returning it to its owner or to his heir if he has died
Question

Someone stole from the wealth of his grandfather and grandmother several years ago, when he was young. He has repented, and he started to return the property to its owners in order to perfect his repentance. Is it permissible to donate the value of the stolen wealth after they have died? That is because it is difficult to contact the heirs, of whom there are many, and because there are many needy people in his city, and he thinks that by doing that, the reward for donating this money will reach them.
Praise be to Allah.In order for repentance to be valid when it has to do with the rights of other people, it is stipulated that the wrongdoer restore the property to its rightful owners, or ask them to pardon him, because of the report narrated by al-Bukhaari (2449) from Abu Hurayrah (may Allah be pleased with him), who said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever has wronged his brother with regard to his honour or anything else, let him seek his pardon today, before a time when there will be no dinar or dirham [i.e., money], and if he has any righteous deeds to his credit, they will be taken from him commensurate with the wrong he did, and if he has no good deeds to his credit, some of the bad deeds of his opposite number will be taken and added to his burden.”
If someone has stolen the wealth or property of another person, and it is too difficult for him to tell him about that, or he fears that more harm will result from telling him, such as if it will cause ties between them to be broken, then he does not have to tell him; rather he should return the wealth to him by any possible means, such as putting it into his account, or giving it to someone who will deliver it to him, and the like.
Secondly:
The questioner must return the money to the heirs of his grandfather and grandmother, even if it is difficult, so long as it is possible.
There is a difference between it being difficult to return the property, when it is still possible, and it being impossible to return it. If it is possible to do so, he must return the property to its rightful owners, who are more entitled to it, and they are the ones who have the right to dispose of this property. It is not permissible for anyone to give someone’s else’s wealth in charity without their knowledge, even if there are a lot of poor people in the city where you live. That does not justify a person giving someone else’s wealth to them in charity; he may give of his own wealth in charity as much as he wishes.
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said: It is essential to return wealth to its rightful owners so long as they are known, or they have heirs who are known. It is essential to deliver it to them. But if you have forgotten them or did not know who they were in the first place, or you have given up hope of finding them, then you should give it in charity on their behalf. But if they are known, or they have died but their heirs are known, it may be difficult for a person to go to them and say, “This is wealth that I took from you unlawfully; please accept my repentance and take it.” This may be too difficult and the Shaytaan may instill in their hearts the idea that you took more than you have given back to them, and so on. In that case, you should look for a man whom you trust, who is of sound mind and religiously committed, and tell him what happened, and that this belongs to So-and-so –  or to his heirs if he has died – and in sha Allah he can help you to fulfil your duty, and he can contact the rightful owner and say: This good person has repented to Allah, and he had wronged you by taking such and such of your wealth, and here is the wealth [which he is returning to you]. In this manner you can fulfil your duty, because the scholars say that in the case of wealth of which the owner is known, it is essential to deliver it to its rightful owner.
End quote from al-Liqaa’ ash-Shahri, no. 31.
For more information, please see the answer to question no. 148902.
If a person fears Allah, may He be exalted, as much as he is able to, and is keen to give people their due rights, then Allah, may He be exalted, will make it easy for him to do that, no matter how impossible or difficult it seems to him to be.
With regard to the questioner saying “he thinks that by doing that, the reward for donating this money will reach them”, the wealth no longer belongs to his grandfather and grandmother; rather it has now become the property of their heirs.
And Allah knows best.