renamed protocol.close to onClose