I have had a period of a month or two in my life where I had similar experiences of that uncontrollable thinking and shakiness and also thought that I might just die or become mentally insane. I never visited a doctor and never used any drugs for it. I'm glad I don't have it now and sometimes I'm afraid it would come back again at some point of my life. I don't know to avoid it, but I read and watch videos about psychology and philosophy a lot which I think helps me to calm my mind and better understand world, society, happiness and other similar topics which I'm really interested in. I can recommend youtube channel "School of life" and spotify podcast "Philosophize This". Also go to another doctor, please. I feel really sorry for you and I hope you will get better soon.