analogWrite inside an interrupt

All variables use both inside and outside an ISR should be declared as volatile.

It is also possible that the timer you are using is involved with the generation of the PWM signal and you are pulling the rug from underneath your self.
Just try using one PWM pin as a test, change the number until layout find one that doesn’t crash.