He wants to stay until his contract expires in 2024. This is a win win solution I think, apart from Ancelotti himself this is a good thing for Real Madrid.
Ancelotti is aware that if he leaves Madrid at this time then indeed he will also be quite hated especially in the approaching time for the new season, obviously Madrid will be struggling to find a new coach so he decided to leave after his contract actually ended.
Now he must enjoy his last season in Madrid and must make a difference at least to give the best impression and experience for him in Madrid before he really leaves.
With one more season remaining I want to see Carlo Ancelotti give several titles to Real Madrid before parting ways next season, there is still a task to be completed especially if they can win the LaLiga and Champions League trophies, of course it will bring a more beautiful impression and there will be hatred for Carlo Ancelotti.
We'll see how Real Madrid will appoint another coach as a replacement for Carlo Ancelotti, but this is not a thought now because the season is still long for them to go through with Ancelotti, about the impression I think the coach will do his best plus Real Madrid's troops have a capable squad as they should it's not hard for Ancelotti.