Going off xanax is an extremely painful and difficult and sometimes dangerous experience...you must talk to your doctor about this an either set up a weaning experience over a 4-5 period; or ask him to substitute klonopin for a month, and then go off of that over a three week period.
I was hooked on Xanax for many years before getting weened off of it and put on the right meds. Your doctor is an idiot, you could have had a seizure. Dr. Gould is correct in his answer. Xanax can also store in your tissues so it takes a long time to detox. Good Luck, it's not easy coming off of it. I feel bad for you because it was very difficult, but I have been off it for 15 years now - thank God!