When the car is scrapped
An authorised treatment facility handles end-of-life vehicles and issues a Certificate of Destruction where appropriate. Check the official DVLA guidance.
When the car is sold
If the vehicle is changing keeper rather than being destroyed, use the relevant V5C process and keep a record of the sale.
This is general information, not legal or financial advice. Check GOV.UK or ask a qualified adviser about your situation.