The rules of cricket
Law 35 (Hit wicket)
1. Out Hit wicket
(a) The striker is out Hit wicket if, after the bowler has entered his delivery stride and while the ball is in play, his wicket is put down either by the striker's bat or by his person as described in Law 28.1(a)(ii) and (iii) (Wicket put down)
either (i) in the course of any action taken by him in preparing to receive or in receiving a delivery,
or (ii) in setting off for his first run immediately after playing, or playing at, the ball,
or (iii) if he makes no attempt to play the ball, in setting off for his first run, providing that in the opinion of the umpire this is immediately after he has had the opportunity of playing the ball,
or (iv) in lawfully making a second or further stroke for the purpose of guarding his wicket within the provisions of Law 34.3 (Ball lawfully struck more than once).
(b) If the striker puts his wicket down in any of the ways described in Law 28.1(a)(ii) and (iii) (Wicket put down) before the bowler has entered his delivery stride, either umpire shall call and signal Dead ball.
2. Not out Hit wicket
Notwithstanding 1 above, the batsman is not out under this Law should his wicket be put down in any of the ways referred to in 1 above if
(a) it occurs after he has completed any action in receiving the delivery, other than in 1(a)(ii), (iii) or (iv) above.
(b) it occurs when he is in the act of running, other than in setting off immediately for his first run.
(c) it occurs when he is trying to avoid being run out or stumped.
(d) it occurs while he is trying to avoid a throw-in at any time.
(e) the bowler, after entering his delivery stride, does not deliver the ball. In this case either umpire shall immediately call and signal Dead ball. See Law 23.3 (Umpire calling and signalling Dead ball).
(f) the delivery is a No ball.