Thanks Stuart. Yes, I agree with your findings. I'd like to propose the following behaviour for the two close buttons:
The system close button
If "Confirm close of program" is enabled, then ask for confirmation before closing, otherwise close immediately.
The program exit button
If "Exit button minimises program" is enabled, then minimise immediately. In this case, if "Minimise to system tray" is also enabled, then minimise to the system tray, otherwise minimise to the task bar.
If "Exit button minimises program" is not enabled, then if "Confirm close of program" is enabled, then ask for confirmation before closing, otherwise close immediately.
I also propose to change the icon on the program exit button so that it looks different to the system close button.
(The background to this proposal is that it's actually rather difficult to make the behaviour of the system close button the same as the behaviour of the program exit button, in a way which will be consistent across all the target systems. So I'm proposing that I make them look different as well as behaving rather differently.)