I don't seem to be able to reproduce the issue here. I'm double clicking on mame64.exe, and navigating the rom's menu to launch 1942. I have defined 1942.ini with a ps_string inside. Everything works as expected, on exit it goes back to the menu, then back to desktop at 640 x 480.
I've had some time to test things.
If I do the same as you and exit back to desktop it's stuck at 400x256. If I run mame.exe from commandline and exit back, then desktop goes back to 640x480. I noticed if I set desktop to highest possible resolution available, i.e. 800x600 and then double click mame.exe, select and launch 1942, then go back to desktop it will actually change back to 800x600. If I set desktop to any other resolution run mame and go back then it won't return back to the previously set desktop res.
If I use GM 0.160 then I don't have any of these problems. Could there be an issue with GM and my AVGA? Could it have something to do with the drivers?
On another note: I have noticed that switchres in GM 0.169 is reporting wrong horizontal frequency (and sometimes vfreq), mainly in vertical games where I have set ps_timing string, although it does in some horizontal games as well.
For example: 1942
Default timing string for 400x256 is 400,22,40,57,256,12,3,26,8071,534 based on what is set by AVGA. This should be Vfreq 52.360 Hz X 297 lines = Hfreq 15.551 kHz
If used in GM 0.160, switchres reports correctly. If used in GM 0.169, switchres reports Vfreq 60.000 Hz and Hfreq 16.620 kHz. Both are wrong. Powerstrip OSD reports correct refresh rates.
EDIT: I forgot to mention here that even though GM 0.169 is saying game is runnng at 60 Hz it is actually running at 52 Hz. Game is very slow

Custom timing string for 400x256, based on my own settings, is 400,10,40,69,256,0,3,16,8564,534. This should be Vfreq 60.000 Hz X 275 lines = Hfreq 16.500 kHz
If used in GM 0.160, switchres reports correctly. If used in GM 0.169, switchres reports Vfreq 60.000 Hz and Hfreq 16.620 kHz. Horizontal freq is wrong. Powerstrip OSD reports correct horizontal freq.
I have attached a log for each of the 4 scenarios. What do you think might be the problem?
As regards my first issue of desktop not changing back, is there any further info I can give you? Thanks for all your hard work.