You control a user's permissions to a course with Enrollments. For example, you can enroll a user as a student, teacher, teaching assistant, or author in a course. To revoke rights to a course, you modify the enrollment.
Caution: student-submitted content is associated with the Enrollment record in the database. Delete a student's enrollment only if it was created accidentally. This preserves student-submitted data even after the enrollment has ended.
To revoke rights to a course, you can change the Enrollment status to Inactive, you can change the enrollment end-date to a date in the past, or you can change the rights associated with the enrollment.
See Enrolling Users and Modifying Enrollments for more details.