If the pipe is suddenly closed at the outlet (downstream), the mass of water before the closure is still moving forward with some velocity, building up a high pressure and shock waves. In domestic plumbing this is experienced as a loud banging resembling a hammering noise. Water hammer can cause pipelines to break if the pressure is high enough. Air traps or stand pipes (open at the top) are sometimes added as dampers to water systems to provide a cushion to absorb the force of moving water in order to prevent damage to the system. (At some hydroelectric generating stations what appears to be a water tower is actually one of these devices, known as a surge drum).
In the home, water hammer may occur when a dishwasher, washing machine, or toilet shuts off water flow. The result may be heard as a loud bang, repetitive banging (as the shock wave travels back and forth in the plumbing system), or as some shuddering.
On the other hand, when an upstream valve in a pipe is closed, the water downstream of the valve will attempt to continue flowing, creating a vacuum that may cause the pipe to collapse or implode. This problem can be particularly acute if the pipe is on a downhill slope. To prevent this, air and vacuum relief valves, or air vents, are installed just downstream of the valve to allow air to enter the line and prevent this vacuum from occurring.
Other causes of water hammer are pump failure, and check valve slam (due to sudden deceleration, a check valve may slam shut rapidly, depending on the dynamic characteristic of the check valve and the mass of the water between a check valve and tank)