If you think that the banging sound you hear when you shut off the shower can't be good for the pipes, you're right. Depending on the pressure, water hammer -- which is the phenomenon causing the banging -- can be strong enough to start a leak. You can avoid it by shutting off the water slowly, but if your children have a hard time remembering to do that, you need another remedy.
The Force of Water Hammer
The flow of water in a pipe is as much about physics as it is about plumbing. The water flowing in a pipe is incompressible, and stopping it suddenly by turning off a valve sends supersonic shock waves through it. The addition of these shock waves to the turbulence already present in the water creates vibrations that rattle the pipes. They can be strong enough to shake joints apart and to create small leaks in old, corroded pipes to relieve some of the pressure. The banging sound you hear is the vibrating pipes knocking against the wall studs.
One of the simplest ways to control water hammer is to turn faucets off slowly, and that's especially important if you have a single-handled faucet that you can quickly thrust to the off position. Even if you operate the valve slowly, there will probably still be a knock when you finally close it, but it will probably too small to cause damage. You can also get water hammer when adjusting the temperature with a single-handle faucet, because certain settings increase water turbulence. If so, instruct everyone using the shower to avoid settings that make the pipes knock.
Adjust Pressure Regulator
You may notice knocking in the pipes even when you aren't using the shower. It could be the result of flushing a toilet, or it may happen on its own for no apparent reason. It probably means -- first of all -- that the pressure in your pipes is too high, but there may be fluctuations on the supply side, which isn't unusual for municipal water systems. If you have a pressure regulator installed near the water meter, you should be able to stop the banging by adjusting it to lower the pressure. Do this by turning the adjustment screw counterclockwise with a wrench.
Water Hammer Arrestors
The best solution for water hammer is to install a water hammer arrestor. It consists of an air-filled chamber and a piston that compresses the air in the chamber to relieve excess pressure in the pipes. It's a simple device that you can purchase at any hardware store, but you have to solder a tee onto the pipe to connect it. To quiet a shower valve, the best place to install it is near the valve, which may require cutting into the wall if you don't have an access panel. You'll also need to shut off the water and drain the pipes.