Gold ends higher after a recent decline to a four-month low