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
Qatadah said: I said to Sa'id bin al-Musayyab (may Allah have mercy on him) that Qadi Shurayh (may Allah have mercy on him) used to say: The kitabah is to be paid first and then the debt, or both are to be shared together. Shu'bah was in doubt. Ibn al-Musayyab (may Allah have mercy on him) said: Qadi Shurayh (may Allah have mercy on him) erred, even though he is a judge. Zayd bin Thabit (may Allah be pleased with him) says: The debt will be paid first.
The Shaykh (may Allah have mercy on him) says: It has also been narrated from Qadi Shurayh (may Allah have mercy on him) that he said: The debt is to be paid first.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المكاتب / 21690
Al-Hakam (may Allah have mercy on him) narrates from Qadi Shurayh (may Allah have mercy on him): If the mukatab dies while owing a debt, the payment of the debt should come first.
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المكاتب / 21691