Add statement to stop thread