@ all ...
I've had this happen but only a couple of times. When something like that happens, have found it's best NOT to panic and close down the browser, but, rather, use the URL line of the browser and erase the ending of the URL up to admin/ (right to left). Hit enter key and found Moodle was attempting to direct me to some setting screen. Saved. And everything ok after good.
Have had to do this once on a stubborn server ...
http://server/admin/purgecaches.php
and it continued so physically removed the contents of:
/moodledata/cache/cachestore_file/default_application
which is what the purgecaches.php script was to do.
At that point, cleared the browser cookies and cache.
Then attempted to login again. Finally, success.
One cravat ... none of the servers I work on are on shared hosting (cheapo plan).
'spirit of sharing', Ken