Pffabrications:
Using an interupt to detect incoming PWM signal then a loop to calculate duty cycle and translate that to desired rpm.This works well until the 0 rpm is requested (which drops the incoming PWM signal back to 0 volts)
0 is not detected and the target rpm remains at the last positive value.
If you note the time of each interrupt and if the interval between interrupts is too long you will know that the stream of pulses has stopped. I use that to detect when a small DC motor stalls.
You have not told us what computer is interpreting GRBL and producing the PWM signal? If you could modify the program so it just sends the number - such as 0 - 255 - it would make life much easier.
...R