Make sure onClose is called once