All children committed to the Department of Human Services or accepted into its custody upon application from parents or guardians shall remain in the custody of the Department of Human Services and subject to placement in its discretion, until released by order of the Department of Human Services or until they arrive at the age of 21 years, when discharge shall be mandatory, except that such custody may otherwise be terminated by the district court or the Superior Court.