From Wiktionary, the free dictionary
Literally, “lose a screw”.
perder un tornillo (first-person singular present pierdo un tornillo, first-person singular preterite perdí un tornillo, past participle perdido un tornillo)
- (idiomatic) to lose one's mind