1. Create an alibi.
The first thing you should do is create a reasonable alibi. For example, if your school has a library you can say that you have a book that is a week overdue that you need to turn in. Or you can say that your stomach or head hurts and that you'd like to rest in the Nurse's Office for a while. Or you can say that you left something important in the cafeteria. (Make sure that if you use the library tactic that you bring a book with.)
Either way, you need to create a reliable alibi so you don't get caught. Make sure that it's something that might actually take a long time or they'll see right past it. I would make sure that you actually have a reputation of being honest before you attempt this stunt or it might not work. And remember that your teacher might still say no if you ask to get out the classroom. You could even see if a friend had 'Headaches' or 'Overdue books' or 'Lost items'. But no more than 1 person or it's too suspicious.
2. Strengthen your alibi.
Next thing you need to do is strengthen your alibi. Walk over to wherever you told your teacher you were going and try to bump into other teachers . For example, if you excuse was the library, make some small talk "Oh hi Mr. Smith! I'm going to the Library to return an overdue book." Make sure you bump into a few teachers, but the more teachers you say hi to, the more you have to avoid for number 3. (Nice transition on my part haha)
3. Sit back and relax!
Finally, go to the place you said you were gonna go and just hang out there for a while. Lay down and chill if you said that you had a headache, look around the cafeteria and lost and found bins if you said you lost something, and look at the bookshelves at the library if you said you were gonna check in your book. It's a good move to actually check in your book and maybe even check a new one out! Just be sure that you go back to class with like 5 minutes to spare, it's a good move to make sure that you don't get caught.