You got lucky with that dwarf. The one time this happened to me, it resulted in mother dead from the beating and baby dead of dehydration. Interestingly, this only seems to happen with nursing mothers[1]. I remember having a dwarf give birth while chained up, and she picked up her baby just fine.
If a chain is not available, the imprisonment gets cancelled and replaced with a beating. Once the beating is delivered, justice has been served. As far as i can tell, the beating is scheduled the moment all chains are unassigned from justice and the captain will not relent until the evildoer has been thoroughly punched.
Punishments can be postponed indefinitely if there's no "officer" available, i.e. no fortress guard to beat/imprison the victim of your noble's ire. Having no officer available can be achieved easily by dissolving the captain of the guard's squad. I don't know how this affects already-active ...justice jobs, they definitely persist for a bit after a squad's dissolved but i haven't checked if they cancel and disappear if you manage to keep ex-officer and "criminal" apart for long enough.
If you ever create a new guard squad, their first job will be catching up with old ...justice work, i.e. imprison and pummel everyone found deserving, even if the offence is twenty years old. So once you abolished ...justice, it's hard to re-install.
[1] could this be the unintended effect of a check to make sure uninvolved units aren't mistakenly brought to the jail? I'm almost certain that some code is in place so that if a dwarf gets caught by the jailer while on a "recover wounded" or "handle animal" job, the wounded or animal doesn't get dragged along to prison. The baby isn't sentenced to imprisonment, so the mother must leave it in freedom...