Gold ends higher as global stock markets pull back