Check onOpen definition instead of onClose