You'd stay until, at some point, the jail would be booked to capacity, and they'd want to book someone new in.
Ficavam ali até que, a certa altura, a prisão estava a transbordar e eles queriam meter mais alguém.