Prevent JK-FF Counter to start from beginning after reaching maximum
Disable the counter when the max is reached. You can do that by passing the clock through a AND gate down to the clock input. The other input is the internal state based enable which you create with an n-input AND gate for detecting max and a n-input NOR gate for min.

When clamping you add the (possibly inverted) direction input pin to the and gates:







simulate this circuit &ndash; Schematic created using CircuitLab