Step 1: Go to the course and then click on "Participants."
Step 2: You will see "Enrolled Users." Click on that, then select "Enrollment Methods" from the dropdown.
Step 3: Click "Settings" on "Self Enrollment (Student)."
Step 4: Remove the enrollment key from the textbox.