Hi @Anastasiiaaa,
It depends on whether you were obliged to take part in the course or not. Some people are obliged to take part in an integration course by either the Ausländerbehörde or the Jobcenter. This is called ‘Verpflichtung’. For such people, stopping the course can lead to problems with having their residency renewed. There are exceptions, such as if the person finds work or is caring for a family member. Here’s more about it:
https://***.mbeon.de/en/information/learning-german/integration-courses/am-i-obligated-to-participate-in-an-integration-course/
If you are taking part in the course on a voluntary basis, then you just need to inform the school that you are stopping the course. You mention a contract. I am not aware of any contract a person has to do a language course. If the course is on a voluntary basis, then you have asked BAMF for permission to take part. They have given you this permission (a paper called a 'Berechtigungsschein'. You do not need to cancel or revoke this permission.
Best,
Éanna