Ibn Jurayj (may Allah have mercy on him) says: I said to Ata' (may Allah have mercy on him): "My mukatab has become bankrupt; he has wealth, and he also owes debts to people. Should I pay the people's debts before my kitabah?" He said: "Yes." Ibn Jurayj (may Allah have mercy on him) said to Ata' (may Allah have mercy on him): "Should I not take a share alongside them for an instalment that had fallen due on him, since I had owned his earnings for his year?" He said: "No."
Imam al-Shafi'i (may Allah have mercy on him) said: This is what we follow. If the mukatab dies, pay off the people's debts first, because he died a slave, the kitabah becomes void, and the master has no debt owed to him by the slave; the remaining wealth belongs to the master.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المكاتب / 21688