Out of one’s wits
Wits is an old English collective noun for mind or mental faculties. Out of one’s wits, therefore, is to be out of one’s mind, hence scared or frightened out of one’s wits. People also live by or on their wits. All these expressions date from the 1500s.