slip a cog
Also, slip a gear or one's gears. Lose one's ability to reason soundly or make correct judgments, as in She must have slipped a cog or she would never have gone out barefoot in December, or What's the matter with him? Has he slipped his gears? These slangy usages allude to a mechanical failure owing to the cog of a gear or a gear failing to mesh. The first dates from about 1930, the variant from the 1960s.
Dictionary.com presents 366 FAQs, incorporating some of the frequently asked questions from the past with newer queries.