Fixing issue #291 (WIP)

This needs to be `if("onunload" in global) {`