When you're actively cycling most of your your blood flow (and therefore oxygen) is directed to your legs. When you stop cycling you need that oxygen in other places but if you stop suddenly it's still mostly in your legs so you may be getting dizzy form lack of oxygen.
That's why we cool down in spin class or before getting off a treadmill.
This should last only a brief time though. If it takes a while to go away or if there is pain involved I would certainly have some testing done.
2008 Trek FX 7.2/Terry Cite X
2009 Jamis Aurora/Brooks B-68
2010 Trek FX 7.6 WSD/stock bontrager