You have to file an application if you want to de-register (Exmatrikulation) and for finishing the master program before the semester ends. Here you can find the application form: Prüfungsbüro. This application determines the date of your university end. The examination office will then hand you out your certificate and diploma as well as a diploma supplement in German and in English which also includes a transcript of records.
If you don't de-register before the university will de-register your automatically at the end of the semester when you don't pay the semester fees for the next semester.
If you wish to do so you can also de-register before when you have finished all the modules. You will also have to file an application for that. That means that you don't have to be enrolled anymore when you're just waiting for your degree but you've already finished everything.