The commissioner of corrections shall detain a convict committed under the circumstances provided for in N.H. Rev. Stat. § 622:17 by virtue of the civil process as well as of his sentence, and, if, at the expiration of the sentence, the civil process is not withdrawn, discharged, satisfied, or annulled, shall still detain the convict thereon until he is discharged or remanded by due course of law.