give upt the ghost: humorous If a machine gives up the ghost, it stops working
out of the Cambridge Advanced Dictionary.
Hope it helps
P.S. If we use it with a person it means to die / pass away
another meaning is : to stop trying to do something because you know that you will not succeed
All I'd cherished from early childhood had been denied me, so I simply gave up the ghost.
Interested in Language