It seems like the fireworks or whatever was making a sound set him on edge so when a figure appeared at the window, perhaps holding something, his brain could have easily told him, “Someone is shooting at me”. That or he could have easily accidentally fired as well.