If the proceedings under this part 9 are terminated by the court, as provided in section 18-1.3-910 or 18-1.3-912 (3), the court shall deduct the time from the commencement of proceedings to the termination of proceedings from the minimum sentence of the defendant.