If it is knocking in the water pipes when you shut off the water suddenly, this is called a water hammer. The pipes might shudder or violently go wham wham wham if the water is turned off quickly. To see if this is the case, turn it off quickly once to see if it makes the noise and then a second time turn it off very slowly. It is usualy the sudden turning off of the water that causes the water hammer. To cure this you can try turning off the water supply and then open all the water taps starting with the highest ones in the house, ending with the lowest one. This will drain all the water out of the pipes. Once the pipes have been emptied, open the house water supply and close the taps starting with the lowest one going to the top. This will fill the pipes with water. Water hammers are caused by air being in the pipes, by draining and refilling you pipes with water in this manner you will minimize the air in the pipes. Another thing to look for is if you have exposed pipes in the basement. You can shove insulation in the hole when a pipe passes through a floor, it is in these holes that the pipes cause the knocking sound.