Keeping prisoners past their terms because of

While I can understand the concerns about whether a person is rehabilitated or not, it seems that if a person has done their time as determined by their sentence, that keeping someone imprisoned for years beyond this date, based on somewhat questionable guesses by psychiatrists about their “state of mind”, seems ethically wrong somehow, even if they are criminals. In essence a person’s sentence means nothing, if the state feels you are not sufficiently rehabilitated.

It’s vaguely like a Soviet gulag where you can be imprisoned indefinitely based on an administrative or psychiatric opinion about your state of mind. Is this the way punishment should work?

From the New York Times

Questions Rise Over Imprisoning Sex Offenders Past Their Terms

Dear mods- There is apparently another thread addressing this same topic that I did not notice. Please close this one.