For sixteen years he remained in the military service of the republic, and took part in the operations of the liberating army in Peru.
Eventually, through a change of administration, he was cashiered in March 1838, and he returned to England in January 1839.