A juvenile in the custody of the department of children's services pursuant to a commitment by a juvenile court of this state may petition for post-commitment relief under this part at any time after the juvenile has exhausted the juvenile's appellate remedies or time for an appeal to the circuit court pursuant to §37-1-159, or the juvenile's appeal in the nature of a writ of error from the judgment of the circuit court has passed and before the juvenile has been discharged from the custody of the department.