I have added a quit option to menu. It works, but it was a bit hard to achieve and I may have broken something else.
I didn't use code injection, just plain old hex editing. There were only 8 unused bytes left at the end of the DialogProc code, and I needed at least 24 bytes to insert a jump address (4 bytes), a call to PostQuitMessage (8 bytes) and the return code (12 bytes). Fortunately the branch table for the WM_COMMAND switch code had 4 unused pointers due to missing resource IDs, so I got the 16 extra bytes by deleting their positions and moving the branch table. Then I had to update the ID values of menu item resources and CheckMenuItem calls to match the new branch table entries.
I think something went wrong because now the program loads a different menu with more options that should only appear when a PowerVR card is installed. Well, at least it still sort of works and doesn't hang the system.