What does MG do after I leave the game? Why it takes so long until I am able to use the menu again?
I don't know the details, but I can try a guess:
It does garbage collection, making sure it deallocates any memory which has been in use during the last game, to allow for reallocating thi memory during its further runtime (in case you start another game). It's not just MegaGlest which needs to do stuff here. Once it deallocates memory the operating system is in charge of managing this free memory again and may do various stuff, such as move memory areas it uses itself around in an attempt to defragment RAM. Also the GPU may do similar (which depends on how the drivers manage it).
What happens if I just close the MG window without terminating it correctly?
This depends on your operating system (and you video drivers) and how well it can handle the case where an application doesn't deallocate RAM it was using. Since the operating system knows which RAM areas are in use by an application, it should be able to forcefully deallocate them when it is killing an application process and this usually works well enough. However, the applicaion does not expect to exit at this point, which could lead to data loss. For example, once MegaGlest will gather statistics on how plaers performed during a game, it will want to report them to a central server by the end of a game. If you would, however, close the game there this could result in these stats not being reported. Similarily, and already now, when a game server process is killed and thus exits out of the expected code flow, it may fail to report back to the masterserver that a game has ended, which may cause the game to be listed there as 'in process' for longer than neccessary.
The main reason the garbage collection is done is most likely to make this memory available for a new game or other data MG may need to store in RAM.