It was narrated from Mu'awiyah bin Qurrah, from his father that the Messenger of Allah (ﷺ) said:
"Whoever makes a will as death approaches, and his will is in accordance with the book of Allah (SWT) it will be an expiation for whatever he did not pay of his Zakah during his lifetime."
English reference: Vol. 3, Book 22, Hadith 2705
Arabic reference: Book 22, Hadith 2809