It is instinctive in animals to seek immediate shelter when they hear thunder or loud noises. If frightened, your cat will run for cover under the bed, into the closet or to the top of a tree (be careful that you're not the tree).
On the other hand, your dog can become extremely destructive in his attempts to reach a safe haven. He might scratch at, chew through, jump over, or jump through barriers to reach a place of refuge. I've seen dogs that have chewed off door jambs, bloodied their paws scratching through a door, and cut themselves badly jumping right through a window.
It's a pitiful sight to behold — your beloved pet so petrified that he is willing to hurt himself, perhaps seriously, because of the intense fear of loud noises.
Your best action this July 4 is to minimize your pet's exposure to fireworks. Keep him indoors in an interior, windowless room. Muffle the sounds by playing your stereo loudly, creating white noise. (I hear a "yessss!" from the teens). Plan on being with your pet; your presence is probably his or her best security blanket.
If your pet shows signs of stress, give him his favorite treats and toys so that he will associate positive things with the loud noise.
Don't coddle him, however. You'll only reinforce that something is wrong. Play with him and reward him; after all, you're trying to convince him that loud noses make good things happen.
Seeing your veterinarian for short term or long term medications may be necessary for moderate to severe cases.