To throw in the towel / To give up
Borrowed from boxing. Used when someone gives up on something they've been struggling with. Can be used literally or to encourage someone not to quit.
She'd been trying for months, but in the end she threw in the towel.
Don't throw in the towel now, you're so close.
—Are you still on the project? —I almost threw in the towel, but I pulled through.