at one's wits' end, to be
To be at a total loss, completely perplexed. “Wits” here means mental capacity or ability to think. The term was used by Chaucer (Troilus and Criseyde) and William Langland (Piers Ploughman) in the late fourteenth century and has been a cliché since the eighteenth century.