I see, but as Kenneth said there too
This is the part I've coded out above to get rid of the red flash
After that you should be good to use your original code.
But my suspicion still stands
I doubt WiFi.off()
kills the suscription, but if it did, I'd expect resubscribing too often might bring in a problem.
I recall that there was some discussion about this, but I'd have to find that thread again.