The endgame is the part of the game which comes closest to being mathematically determined. In essence if there are 7 pieces or fewer left on the board then the result of the game with best play is known and can be looked up in the tablebases.
Further, there are many kinds of endgame positions with more than 7 pieces where it is clear to a player with the right "endgame knowledge" either which side is winning and the general process for winning the game or that the game should be drawn and what the drawing principles are for each side.
Ultimately there are different classes of positions with different algorithms for winning or drawing the game.
Consequently what goes through my mind are a series of linked questions:
- Am I winning? (OK, it should really be "What is the evaluation here?" but I'm more self-interested than that)
- If I am winning then do I know how to win? I can certainly know that I have a winning position with KNB vs K without knowing exactly how to win. If I don't know exactly how to win can I remember enough of the ideas and principles of the winning algorithm to realistically play for a win, to have a plan to keep me going.
- If I am losing do I know enough about my opponent's winning algorithm to make it as difficult as possible for them to win? There are the 3-fold repetition rule and 50-move rule for me to aim for for my salvation.
- If the game should be a draw do I know why and how I need to play to ensure the draw if I am on the weaker side and conversely what I need to trick my opponent into playing if I am on the weaker side?
There is a lot of knowledge of endgame structures and patterns involved here which is why at all levels of the game, from beginner to world champion, endgame study is a key component of maintaining and improving the level of play.