The main thing is to want to quit, and to keep having that desire, in the face of an addiction that keeps trying to dominate your motivational system. Do things that support your desire to quit, whatever they are. For a lot of people, treatment helps them to stay on the new course, as do 12-step and other programs. If what you are trying to quit is illegal, the justice system might help you to have the right motivation, to abstain rather than go to jail.
The necessary thing is to have enough desire to quit to be able to keep empowering your support system, and to actually keep empowering your support system.