In all cases of commitment under this chapter the person committed may, in case of inability to perform the act required or to endure the imprisonment, be discharged from imprisonment by the court or judge committing him, or the court in which the judgment was rendered, on such terms as may be just.
SDCL 15-20-20