I was tired of my students always interupting me to use the bathroom while I was teaching so I made a system. The students get two "tickets" at the beginning of the day. They may use the tickets to use the bathroom, go to the lockers during class, get drinks; basically anything out of the room during class. They turn in one of their tickets for each time they leave. If they already used up both their tickets and they have to use the bathroom as an emergency, I let them, otherwise they can't leave until the bell rings. It works out very well!