Jami` at-Tirmidhi, Book 17, Hadith 1 (Tirmidhi 1439)

Narrated 'Ali:

That the Messenger of Allah (ﷺ) said: "The pen has been lifted from three; for the sleeping person until he awakens, for the boy until he becomes a young man and for the mentally insane until he regains sanity."