The game ends when the board is full and no two matching tiles touch, so no move in any direction can change the board.
2048 ends when you are out of moves. That is the case only when two things are true at once: all 16 cells hold a tile, and no two touching tiles have the same number.
A full board is not always over
If the board is full but two equal tiles sit next to each other, a slide can still merge them and open space, so the game goes on. It is over only when every direction leaves the board unchanged.
After game over
You can undo moves to step back before the board locked, or start a new game. Your board and personal best are saved in this browser (how many moves you can undo). To stay alive longer, see the 2048 strategy guide and the full rules.