Hadith.5469 - And a confirmation of this is what was narrated by Ismaʿil ibn Abi Ziyad Al-Sakuni from Imam Jafar ibn Muhammad Al-Sadiq (as) from his father, Abu Abdullah Imam Muhammad ibn Ali Al-Baqir (as), that he was asked about a man who dies without leaving behind an heir or any male relative (Aṣabah).
Imam (as) said
"He may bequeath his wealth as he wishes among the Muslims, the poor, and the wayfarer."