EDIT: Please see John's answer above, which basically tells you open Terminal and run:
sudo ./airport en1 prefs DisconnectOnLogout=NO
en1 is the name of your Mac's WiFi interface. You can get it with this Terminal command:
ifconfig | grep -B 6 'status: active' | head -n 1 | cut -d : -f 1
when WiFi is the only active interface (that is, no Ethernet cable attached).
To list the interface settings, run in Terminal:
./airport en1 prefs
Typical output is:
AirPort preferences for en1:
Unable to retrieve JoinMode
Other people's Macs are misbehaving in a similar way, read for example this and this. Although I own a similar MacBook Pro that runs 10.8.2 I can count myself fortunate not to suffer this issue.
Consequently the list below is rather a compilation of possible fixes (some may even seem absurd or just plain obvious) than tested recommendations:
I checked the power management settings (command
defaults but couldn't find anything.
(My setup is: clean "Mountain Lion" install (with restore from Time Machine) and Airport Express base station.)
Hope this will help...