I note that "jig" can be spelled either way.'Jig' is a very old term for a lively dance, but in Elizabethan times the word became slang for a practical joke or a trick. 'The jig is up' - meaning your trick or game is finished, has been exposed, we're onto you now - derives from this obsolete slang word, not the 'jig' that is a lively dance."
When someone says the "gig" is up, they mean that an engagement has played its course.
When someone says the "jig" is up, it indicates that a scoundrel has been found out, and the forces of law and order are on their way.