Overly fancy.  Just make `onclose` the name of the function, and then pass it as an argument.