onClose should not be global.