Pop One’s Clogs

What does the idiom “Pop One’s Clogs” mean?

Definition:

To die.

For example:

“In most movies, there’s a happy ending and the villain pops his clogs.”