If the situation is as described regarding the endowment on the well, and it is no longer required, the piece of land must remain as an endowment and its yield must be spent on facilities for the people of the area where the well is situated. Examples of which include building a mosque, or its renovation, or building a centre for Qur'an memorization, or helping the poor and needy of the town and the needy kin of the donor. These have more right than others to take from the yield of this endowment.
If the lawful benefits required that the land be sold, due to it no longer being useful or being of little use, and its price is used to buy some other piece of land which provides a greater revenue, then there is no objection to that. This is the case, after obtaining the permission of the judge in that town, then spending the income from the purchased land on what we have mentioned above. As for the heirs of the donor, they have no right upon it since they are his heirs, for endowments are not inherited. But there is no objection to them being given assistance from its revenue if they are poor, as was mentioned earlier. And Allah is the Granter of success. And may peace and blessings be upon our Prophet, Muhammad and upon his family and friends.
Ma'ad: A Measurement