External Interface

Currently I’m trying to call a window.close with external interface. It works fine, however, I also have a window.beforeunload call in my javascript so the close button ends up calling two windows. One is the “this page is trying to close…blah blah blah” and the other is the custom one i wrote.

Is there anyway to call onbeforeunload combined with window.close from external interface so that i only get one warning?