Afraid not, @Sophie08 - you will have to settle your device plan in full. If your handset is in excellent condition, and is a premier model, you may be able to get back some of its value through, for example, CEX - once you have paid off the device plan in full. Guide: Cancelling Your Contract Also O2 have begun performing credit checks upon upgrades in recent times, so make sure your current Device and airtime plans are fully settled before embarking on a new contract with O2. Good luck!
Just to elaborate a little on the CEX point that @pgn has made, you can :-
a) sell your handset on the High Street to CEX or to another secondhand mobile 'phone seller.
b) sell you handset privately using a platform such as Ebay.
c) trade-in your handset for a new one from Samsung, Apple or similar - there are some good Black Friday deals around at the moment.
However, as @pgn has indicated, you will need to have paid-off the device plan in full before selling it or trading it in.
I would not heartly recommend any of these options to anyone..
CEX will give you the lowest price possible for the phone, as they want to maximise profit, and to get anything near a decent amount it has to be in mint condition, all the accessories, box... (best of the worst options)
Seller beware when using Facebook Scamplace, as lots of scammers on there, and people have also been attacked and robbed... (https://www.bbc.co.uk/news/uk-england-south-yorkshire-67228265), fleabay is just as bad at times...
Have a look at places like spring.co.uk (they seem to have a good reputation), for recycling phones..
And you can sell it before your contract is ended, as long as you continue to pay off the device plan..