the knocking is called water hammer and usually comes from the ball valve in the cold water storage tank that supplies water to the how water cylinder. The knocking is caused as the baal valve passes less water as it starts to shut down but the mains water pressure is so high that the ball starts shaking, thus causing the noise and the banging in the pipes.
The noise from the toilet may be the ball valve in the cistern doing the same thing, but if the toilet is fed with water from the storage tank then the cause will again be the ball valve in the storage tank.
Ways to cure the problem are to fit a high pressure restrictor in the inlet side of the ball valve or, in my opinion a better way, to fit a pressure reducing valve on the cold water supply pipe where it enters the property.
Hope this helps