When someone burps in a quiet classroom it can be hard to refrain from laughing. Use the verb refrain if you have a sudden impulse to do something and you have stopped yourself from doing it.
It's usually hard to refrain from doing something: you might find it difficult to refrain from eating dessert after dinner, for example — especially when your aunt makes her double chocolate chunk brownies. The Latin word refrēnāre is formed from the prefix re-, "back," plus frēnāre, "to hold a horse back with a bridle." No need to hold back when using refrain as a noun; it’s the part of a song or poem that repeats.