The Messenger of Allah ﷺ said, "Whoever, when death approaches him, makes a will in accordance with the Book of Allah, his will serves as an expiation for the zakat he failed to pay during his lifetime."
حدثنا يحيى بن عثمان بن سعيد بن كثير بن دينار الحمصي حدثنا بقية عن أبي حلبس عن خليد بن أبي خليد
قال رسول الله ﷺ من حضرته الوفاة فأوصى وكانت وصيته على كتاب الله كانت كفارة لما ترك من زكاته في حياته
No references are available.
[Its chain is daif] Daraqutni reported it 4/148, 149 through the hadith of Baqiyyah, with this wording. Busiri said, "This chain is daif. Baqiyyah (551, 1121) is a mudallis, and his teacher Abu Halbas is unknown." Khulayd and his student are both unknown, as stated in Taqrib and elsewhere. The hadith has daif corroborating narrations in Tabarani 33/19 and elsewhere.