You can either just stop taking the medicine cold turkey, and it will be hard but faster... or you can do it gradually. I would try meeting with your doctor to see if there's a replacement option. I assume you needed the pills to treat headaches? It will be hard at the beginning, like breaking any addiction, like smoking or cracking your knuckles, but if you make up your mind to stay away from the pills and stick to it, you'll feel accomplished and much better.