I'm currently quitting smoking heroin myself, which was the single dumbest thing I've ever done. It started a year ago when I was in a super-mild withdrawal from a pain killer habit I'd started a few months before. A friend said "Hey, they're the exact same thing as pills, they just don't have the symbol stamped on them." At first they didn't do much for me, then within a couple weeks I figured out how to kind of smoke them, then within a month I'd gotten my hand on some good stuff and smoking heroin was my new favorite thing in the world. As soon as I woke up, all the way till I went to bed, I LOVED smoking. Seen the movie Limitless where a pill turns him into a genius with unlimited energy? That's what H did for me. And then I started to learn about the withdrawals. Fast forward a year and $20k later, I've finally gotten out from under their spell. I'm not saying I won't smoke again, but I do know I can't make anything a daily habit ever again or I'll go back to square 1 and suffer this all over again. However, with the use kratom, loperamide, and Vitamin C, I'm going on day 4 of no REAL opiates.
So, to answer your question, the only other time I've been addicted to drugs, was in my mid twenties to early 30's I started taking xanax to sleep. Started off just to sleep, until my business got investigated and all kinds of other problems and long story short, I was taking 5mg of xanax a day when I finally went to rehab. For me, rehab was the only way to possibly get off of them. I'd tried on my own for the last year and it was hopeless, and I just kept spiraling further out of control. I went to a place called Narconon in California, which is a very holistic form of treatment using saunas and nutrition, once you do a medical detox of course. I won't like, the first 30 days were like crawling through the 7th layer of hell. I couldn't sleep, I was a social nightmare, so full of anxiety, panic, and all kinds of other horrible feelings that I didn't think it would ever end.
Then the sauna portion of the program finally started and within 72 hours of sweating like a maniac, I started to feel normal again. Finished the sauna in another 20+ days and felt better than I ever had in my entire life. Problem is, my then wife really got into the L. Ron Hubbard stuff and followed it hardcore to the Church Of Scientology, and it led to a divorce. Combine that with some other health problems which I JUST REALIZED ARE FIXED BY DIET, and that's what led to smoking H. Of course, for me, smoking H wasn't like other people doing H who crawl into a ball and just get hi. It motivated me, drove me, pushed me, problem is it pushed me too far.
To answer your question, lol, rehab is sometimes the only way. You will hate it and wish you weren't there in the beginning, but if you really want to be free again, and not have an addition run your life, it is every bit worth it.