I thought it stopped working because it had a bad temper. Seemed to run just fine when it zoomed off into the enchanted forest.
Anyrate, I fail to see how a device such as a gun would stop working. If nothing else, he could have brought a flintlock: assuming that a flintlock wouldn't work at Hogwarts would be like saying that flint hitting metal doesn't cause sparks at Hogwarts, or that gunpowder doesn't explode at Hogwarts.