Earlier, Dennis Rassmusen scored the winner into an empty net with 34 seconds remaining for Sweden to beat Latvia 5-4.
Latvia needed a win in regulation to keep alive hopes for a quarterfinal spot in the Group B game in Bratislava. After Roberts Bukarts tied the game for Latvia at 4-all with 3:24 remaining in the final period to complete his hat trick, the Latvians pulled the goaltender for an extra attacker.
Latvia’s loss confirmed the four quarterfinalists from Group B: Leader Russia, the two-time defending champion Swedes and the Czech Republic, and Switzerland.
Elias Pettersson, Adrian Kempe, Anton Lander and Hornqvist had a goal each for the Swedes. William Nylander had two assists to lead the scoring list with 15 points.
In Group A, Ben Davis scored 2:03 into overtime for Britain to complete an unlikely comeback and edge France 4-3 to avoid relegation at the expense of the French.