Your wits are your ability to think clearly and quickly. If the class lizard escapes, you can panic — or you can keep your wits, calmly catch him in a box, and return him to his terrarium.
The word wits is used to describe a person's collective mental faculties. If you hang onto your wits in an emergency, that means you remain resourceful and capable. On the other hand, if haunted houses scare you out of your wits, you will probably lose your ability to keep calm and collected at the first sight of a vampire. Wits, like wit, derives from the Old English gewit, "understanding or sense."