Allah, glorified be His praise, says: "And those of your slaves who seek a contract (of emancipation), make a contract with them if you know any good in them." [Surah al-Nur: 33]
Imam al-Shafi'i (may Allah have mercy on him) said: "In this is evidence that Allah Almighty permitted a contract of emancipation (kitabah) only with a (slave) who understands what he is seeking, not with one who lacks the understanding to seek kitabah, such as a child or an insane person."
Hadith Referenceالسنن الكبرى للبيهقي / كتاب المدبر / Q21600