Yeah, neither alternative is good.  How about we attach the onClose event in both cases, but provide an option to disable it in cases where someone "knows what they're doing".