Kiddushin 21 - Hebrew Servant Wants to be Free Again
A Hebrew servant who has sold himself into servitude and wants to redeem himself early enjoys a special privilege: his redemption price is the lower of his purchase price and the current value of his service for the remaining years.
Through the sequence of Torah passages, we can deduce which transgressions caused him to become poor and sell himself. Still, now that he wants to become free again, he gets a leniency.
He can reduce his remaining years of servitude with a partial payment, but this can result either in a gain or a loss for him, if his price fluctuates.