There are different regulations in each state as to when compulsory school attendance ends or when a pupil can be released prematurely from compulsory education upon application by the school board.
For Thüringen applies: The full-time compulsory education beginning with the enrolment in a primary school lasts 9 school years and includes the attendance of a primary school and a secondary general education school of secondary education (Hauptschule, Realschule, Gymnasium, Sekundarschule or Gesamtschule).
Compulsory education in full-time school ends when the pupil has reached one of the qualifications scheduled for the ninth full-time school year. Thereafter, mandatory vocational schooling begins for a period of three years or until the end of the vocational training relationship. The total duration of compulsory education is usually 12 school years.
For details see: http://apps.thueringen.de/de/publikationen/pic/pubdownload1245.pdf