The Prophet ﷺ said that when a person dies all his deeds cease except three: an ongoing charity (ṣadaqah jāriyah), knowledge from which people continue to benefit, and a righteous child who supplicates for him. So endowments like a dug well, a built masjid, or a donated muṣḥaf, beneficial teaching or writing that keeps guiding others, and raising pious children who make duʿāʾ are investments that keep earning reward in the grave. This is why a believer strives to leave such lasting good behind while he still has the ability.
Evidence — the daleel
Sahih Muslim 1631 Ṣaḥīḥ
On deen2u
Informational, not a personal fatwa. Consult a qualified scholar for rulings on your situation.