This sounds like vertigo which seems to be a symptom of hypothyroidism. It could be entirely unrelated but if you keep getting it, it is likely thyroid related.
Mine has been much better over recent months but I'm not sure what helped; sorting out my adrenals, taking B vitamins, sorting my vitamin D deficiency or something else. I know vertigo can be caused by calcium crystals in the semicircular canals so perhaps this is related to vitamin D. I don't really know, except to say that many people with thyroid problems also seem to suffer with vertigo.
It is nasty isn't it! I hope it clears up too. It's horrid when the room spins when you are trying to sleep
Definitely follow the above advice about B12. It could be the B12 supplements that I was taking that helped mine. Who knows?