Set a timer on your phone, for just two minutes at first. when you get close to the edge, start it, and as soon as that alarm goes off, you pull away, sit on your hands, pull pants back up whatever.
Once you’ve got back full self control, do it again, three minutes or four, and again, pull away when it goes off. Keep doing this as you learn to stop after longer and longer periods.
Either this will help you stop in general,or failing that you can set yourself a timer, ten, 15 minutes where the alarm goes off and you DO stop.
Let us know how you get on!