How to set quit only when its last window

Hi,

I am using this option to quit app when I click on red close button, like it happens in windows.
However, I have one problem, if another dialog or window is open, it quits the whole app, which is expected behaviour. However, I want it to only quit if it is the last window.

For example in Final cut, if I hit close red button on a window inside like render dialog, it quites the whole app. I just want it to function if it is the last window of the app. Can anybody help regarding this?

Thanks in advance.

Maybe check the following - Please allow application to quit when last window is closed - #26 by jeff ?