The provisions of § 17a-498 shall apply to any person regarding whom proceedings for commitment are being instituted under § 17a-513 or 17a-514, and to any other person in the custody of the Commissioner of Correction, except that if the court revokes the order of commitment, the person shall be returned to any institution administered by the Department of Correction as the Commissioner of Correction shall designate, unless his custody in the Commissioner of Correction has terminated, in which case he shall be discharged.