If the player cannot do any legal move despite the fact that his King is not in check it is called stalemate. and the game ends as a draw. As you see in the diagram: Black to move but he has no legal move.
Diagram A , Game Adams - Dimitrov : Adams (White ) prevented the defeat after Qh3+ ( check ) . Black must capture the Queen in order to not lose his queen.
Diagram B :
The stalemate occured after Black Queen had captured the White queen: QxQ. White King has no move to do.
After the Queen and the Rook sacrifice of Black, the game ended in a draw because of stalemate.
White seems to be checkmated but he sacrifices his Rook and the Queen ( after pawn promotion) and prevents the defeat thanks to the stalmate.