Getting sacked by Real Madrid's bosses is not inconceivable

There have been a few coaches already who thought that they position as a coach would be save because they were doing alright, but out of a sudden they were told they can leave the club. I would never rule out the possibility that Ancelotti gets sacked or leaves early, but I agree that it seems more likely he will fulfill his contract. Then again it happened so often that I thought a coach would be safe. You can see the opposite can be true, as it is for ten Hag. A crappy coach who is still safe.
Ancelotti future at the Santiago Bernabeu really depends on the number of trophies he is awarded, the number of years on his contract is just a formality for Perez, he is willing to pay compensation if Madrid experiences a decline in performance under Ancelotti leadership. But I think that is still very far from speculation, now the cold hands of the man from Italy are polishing Madrid to the championship ladder.
Throughout his managerial career, Ancelotti has never been the head coach of any national team, it is recorded that Ancelotti was only the assistant coach of the Italian national team in 1992-1995. Most recently, Ancelotti admitted that he once communicated with the Brazilian Football Federation (CBF), the situation changed after the CBF President was replaced, and Ancelotti renewed his contract with Los Blancos.
It could be that in the future Ancelotti will have another opportunity to coach one of the national teams, age is just a number and it's not a big problem. Van Gaal coached the Dutch national team at the Qatar World Cup at the age of 72, I think Ancelotti can surpass that record if he is not constrained for anything.
I am quite sure that this is his plan. He wants to appreciate the time with the club he thinks is the best in the world and he is so closely connected to and I believe when grandmasters like him come closer to the end of their career, maybe they regret some of their words when a few years ago they let everyone know that they would retire early and not sit on the bench as a grandpa. But Ancelotti loves the game and he isn't just there yet to lean back and only coach a national team every one in a while. He knows that closing this Real Madrid chapter means a big step towards retirement for him.