Thinking is a natural function of the mind; there is no need to stop thoughts from occurring. When you are meditating and you realize that you have been lost in thought, simply return your awareness to the object of your meditation. There is nothing more to it than that. You may even take your thoughts as the object of meditation, or rest in open awareness, letting thoughts come and go without paying too much attention to them. The key point is that thoughts and distraction are a natural part of meditation. As you grow more and more familiar with meditative awareness, thoughts will bother you less and less. You may even find that thoughts actually help your meditation, insofar as they are one more experience that you can use to expand your awareness.