In order to achieve the "raid" objective, all you need to do is end one turn in possession of the settlement. If you then leave it or if you own it for ever, it doesn't matter.