Unless you're dealing with a large snake that can really hurt you, a better thing to use would be a dab of vinegar. Or a dunk in cold water (under faucet, or using the snake's bowl of water) will usually startle them enough to let go, without harming them.
But now you'll be better prepared, hopefully to prevent this situation from happening, but also what to do if it does.
Anytime you're not sure what your snake is thinking, show them something NOT edible & NOT appetizing first -like your sleeve, or the cardboard roll from paper towels, so they get the idea it's not incoming food. Always pay attention to what signal you might be sending to your snake, & make sure they read you correctly.