On January 1st, 2051 every game "ends" in a way that you are presented with a fullscreen newspaper article that congratulates you with your achievement. Furthermore, the current performance rating (you can view your current rating from the Detailed Performance Rating window) is added to the High score chart.
Despite the fact that a game is considered "finished" in 2051, you can still keep playing the savegame for as long as you want after 2050.
Trivia
Old versions of OpenTTD had an option to select the end year. This however never worked properly (the game still ended in 2051 regardless of the setting) and has since been removed. It is unknown if a setting like this will return in the future.