What does ‘Leg it’ mean?

Make a run for it; run away; scarper.

“That’s when all of the lights came on, and so we legged it.”