From Sahih Muslim (Hadith 4142):
Ibn 'Abbas (Allah be pleased with them) reported Allah's Messenger (ﷺ) as saying:Give the shares to those who are entitled to them, and what is left from those wno are entitled to it goes to the nearest male heir
Reference: Muslim 4142