Will the debtor be regarded as no longer liable if the government or bank waive his debt?
Question

I am of understanding that I am punished if I do not payoff all my debt before I die. My question is am i still punishable if i do not pay off my debt but instead the government or bank write off my debt (if my assets do not cover the debt) after I die?
Praise be to Allah.Firstly:
The Muslim should not be careless about the matter of debt, and he should not take on any debt except in the case of need. If he does take on a debt, then when he is able to pay off his debt, he should do so, without any further delay. If he is not able to pay it off, then he should leave instructions to his heirs or ask the creditor to let him off.
Muslim narrated in his Saheeh (1885) from Abu Qataadah (may Allah be pleased with him) from the Messenger of Allah (blessings and peace of Allah be upon him) that he stood up before them and said to them: “Jihad for the sake of Allah and belief in Allah are the best of deeds.” A man stood up and said: O Messenger of Allah, do you think that if I am killed for the sake of Allah, my sins will be expiated? The Messenger of Allah (blessings and peace of Allah be upon him) said: “Yes, if you are killed for the sake of Allah and you are patient and seek reward, facing (the enemy) and not turning away.” Then the Messenger of Allah (blessings and peace of Allah be upon him) said: “What did you say? He said: Do you think that if I am killed for the sake of Allah, my sins will be expiated? The Messenger of Allah (blessings and peace of Allah be upon him) said: “Yes, if you are killed for the sake of Allah and you are patient and seek reward, facing (the enemy) and not turning away, except debt, for Jibreel (peace be upon him) told me that.”
Ibn al-Jawzi (may Allah have mercy on him) said:
This hadith contains a warning about debt, because the rights of other people are a serious matter that prevents one from entering Paradise until they are fulfilled. At the beginning of Islam, the Prophet (blessings and peace of Allah be upon him) would refuse to offer the funeral prayer for one who had died in debt. All of that serves as a warning concerning the rights of other people, so how about if one wrongs them?…
It is preferable to avoid debt, because in most cases debts are only taken on for the sake of luxuries.
End quote from Kashf al-Mushkil min Hadeeth as-Saheehayn (2/150)
Secondly:
If a person takes on a debt for a good reason, and he intends to pay it off:
If he could afford to pay off his debt, but he died before it was due to be paid, or he was not able to pay it off, but he left instructions to his heirs to pay off his debt, then he has done what is required of him.
If he could not afford to pay off his debt, but he intended to pay it off, then there is the hope that Allah will pay off his debt for him to his creditor.
Ahmad (24455) narrated that ‘Aa’ishah said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever among my ummah takes on a debt then tries hard to pay it off, but dies without having done so, I am his wali (i.e., I am responsible for his debt).”
Classed as saheeh by al-Albaani in Saheeh at-Targheeb (1800).
Al-Bukhaari (2387) narrated from Abu Hurayrah (may Allah be pleased with him)  that the Prophet (blessings and peace of Allah be upon him) said: “Whoever takes people’s wealth, intending to pay it back, Allah will pay it back on his behalf. Whoever takes people’s wealth, intending to consume it (and not pay it back), Allah will destroy him.”
At-Tabaraani narrated in al-Mu‘jam al-Kabeer (1049) that Maymoonah said: I heard the Prophet (blessings and peace of Allah be upon him) say: “Whoever takes on a debt, intending to pay it off, Allah will pay it off on his behalf on the Day of Resurrection.”
Classed as saheeh by al-Albaani in Saheeh al-Jaami‘ (5986).
“Allah will pay it off on his behalf” means: He will help him to pay it off in this world or He will compensate his creditor in the Hereafter so he will be pleased. End quote.
Mirqaat al-Mafaateeh (5/1957)
At-Tirmidhi (1078) narrated that Abu Hurayrah said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “The believer’s soul is detained by his debt until it is paid off on his behalf.”
Classed as saheeh by al-Albaani in Saheeh at-Tirmidhi.
Ash-Shawkaani (may Allah have mercy on him) said:
This indicates that it is encouraged for heirs to pay off the debts of the deceased, and it informs them that his soul is detained by his debt until it is paid off on his behalf. This applies specifically to the one who has wealth with which his debt may be paid. As for the one who has no wealth but died intending to pay off his debt, there are hadeeth reports which indicate that Allah, may He be exalted, will pay it off on his behalf.
End quote from Nayl al-Awtaar (4/30)
For more information, please see the answer to question no. 118124
Thirdly:
Bankruptcy does not lead to waiving of debt; rather the debt remains due until the person is able to pay it off, or someone else pays it off on his behalf, or the creditor lets him off.
If the government takes your property as collateral for the debt but it is not enough, so they wrote off your debt, then one of the following two scenarios must be the case:
1. This debt was owed to a specific person and was waived in accordance with man-made laws upon proof of bankruptcy; this debt remains in effect and is not waived, even if the court has written it off.
2. The debt is owed to the bank or the government, then they took your property as collateral but it was not sufficient to pay of the debt, so they wrote off the remainder, because you are unable to pay it off. In this case, you do not have to do anything, because the creditor has written off the remainder of the debt. But if they wrote it off unwillingly, rather it was done in accordance with the law of the land, then the debt remains due and must be paid off when you are able to do it, or you must leave instructions in your will that it be paid off, unless you are completely unable to pay it off. In that case, if your inability to pay it off is for a genuine reason then Allah will pay it off on your behalf, as mentioned above, and you will not have to do anything.
In fact, being certain that it is written off willingly in such cases is difficult or impossible, because the debt in this case is not something owed to a specific person who could give consent or approval willingly; rather it is owed to an organisation or body, in which case the one in charge does not think of the matter in such terms. Rather what usually happens in such cases is that they are handled in accordance with the law that applies to the lending body. Hence it is not possible for the bank manager or the like to waive the debt, even if he wants to do so, unless there is a law which allows that in such cases.
But if the debt is owed directly to the government or to a body that is owned by the government, and the debtor dies without having the means to pay it off, and the government writes off the debt, then it is waived and the debtor does not incur any sin or shortcoming, because it is his right over the government that it should help him in this situation: it should pay off the debt owed by one who is in difficulty from the public wealth, so how about if the debt is owed directly to it?
Al-Bukhaari (8/150) and Muslim (1619) narrated from Abu Hurayrah (may Allah be pleased with him) that the Prophet (blessings and peace of Allah be upon him) said: “I am closer to the believers than their own selves. Whoever dies owing a debt, I will repay it, and whoever leaves behind wealth, it is for his heirs.”
Al-Haafiz Ibn Hajar (may Allah have mercy on him) said:
Was this something that applied only to him, or is it a duty of those in authority after him? The more correct view is that it continues to be the case, but the paying off debts is only to be done from the public wealth allocated for that purpose.
End quote from Fath al-Baari (12/10). See also: Nayl al-Awtaar (4/31)
And Allah knows best.