It can be a form of punishment but it’s actually more useful as a way of dealing with going over the edge, AS you do it – to stop yourself having a full orgasm.
Very simply you stop stimulating yourself as you begin to climax, just hands off, toys out, etc. And it’ll happen.
For a long description here’s a post I made earlier