Scotland’s only oil refinery will close in the second quarter of 2025 with the loss of 400 jobs, it has been confirmed.