Attendance contributes 5% of the grade, I take it at the beginning or at the end of the class. May be a possible solution is to start taking it at random times?
Others already mentioned that students can have valid reasons to leave your class for 10 minutes, among other [*]:
- health issues (anxiety issues, bladder problems, a bad back, etc.)
- family emergencies (which can be quite regular in some cases)
Punishing them for these issues would not be the right thing to do, and it might very well violate your schools non-discrimination policy.
You should also keep this in mind when talking about the issue in class (because it can - depending on the situation - easily come across as public shaming and thus 1. discourage students from taking your class and - again - 2. violate the non-discrimination policy).
[*] If your students are leaving in small groups, these reasons could also explain that (good friends helping with an anxiety attack for example).
Suggestions on handling this
Ignore it. There are enough valid reasons that students might step out[*], and honestly, non of them are any of your business. And the students are already punished: They missed part of the class, and possibly cannot follow the rest of the class that well because of missing information, so they have to work at home to catch up.
If you still want to take action:
- try to apply for a room that has exits at the back
- analyze your material: are there parts of your class that are boring/unnecessary? students might be leaving because of this
- create a questionnaire asking about this, which the students can answer anonymously
If you want to talk with the students about it:
- do it privately and individually
- apologize for bringing it up in class in front of everyone, suggesting that they have poor etiquette, and asking them to not come back
- don't ask for their reasons, or at least accept "private" as a valid answer
- ask how you can help them (for example, provide them with a seat closest to the exit)
[*] This is still true if some students step out just because they want to smoke. It is not ok to punish the students with good reasons along with the students with bad reasons.