 Shortly afterwards, the king himself was also deprived of power.Castelo Melhor went into exile in Paris and then London, but in 1685 he was permitted to return to Portugal and, two years after that, to court.On the accession of John V (1706), he was appointed a councillor of state and he continued to occupy a position of distinction until his death in 1720.