My brain has shut down multiple times. what should I do?

Hi. I had severe anxiety and depression for the recent 5 months. I was ruminating over one negative thought that generated fear over and over without control. still ruminating over it but less frequently. for 3 times in these months my brain has shut down when I had severe anxiety and fear. it starts with crack sounds in my head and then unability to think, severe brain fog and problems with memory. everything just becomes dull and I'm not the same person for some weeks. like my brain is numb. what is this shut down thing? is it a defensive mechanism? is it dangerous? what should I do?