Hi Sammarco96,
Please see the following Guidance and detailed notes about leaving the UK to live in Spain -
Living in Spain - in particular please refer to the Headings Tax and National Insurance and Social Security Contributions. You will need to complete the Form P85 when you leave the UK.
Thank you.