During TSN’s coverage of Tuesday night’s game in San Jose, it was mentioned several times that it was a “must-win” for the Canadiens.

It really was with the Canadiens looking to end a five-game losing streak (0-4-1) while playing against the worst team in the NHL. Another loss would have been devastating to the Canadiens’ hopes of remaining in the mix for a playoff spot.

The Canadiens ended up beating the Sharks 4-3 with Joel Armia scoring the winning goal short-handed at 15:56 of the third period. The win left the Canadiens — who improved their record to 25-23-5 — five points out of a wild-card playoff spot in the Eastern Conference.

As head coach Martin St. Louis put it recently, every game now is the biggest game of the season for the Canadiens, including Wednesday’s matchup against the Kings in Los Angeles (10:30 p.m., TSN2, RDS). While the Canadiens were only five points out of a playoff spot after beating the Sharks, they were also only three points ahead of their pace from last season when they had a 22-23-8 record after 53 games and ended up finishing 28th in the overall NHL standings.

Will the Canadiens end up being a playoff contender, or are they destined to be in the NHL Draft lottery for the fourth straight season?

Injuries to defenceman Kaiden Guhle and Emil Heineman were big blows and it seems unlikely the Canadiens will make the playoffs. But the win over the Sharks provided some hope for staying in the mix.

Armia scored a short-handed goal for the second straight game and continues to be a force with Jake Evans on a Canadiens’ penalty-killing unit that ranks ninth in the NHL. The Canadiens went 2-for-4 on the power play, getting goals from Cole Caufield and Brendan Gallagher. It was Caufield’s team-leading 26th goal of the season, but his first on the power play in 31 games.

Canadiens’ Brendan Gallagher, bottom right, scores his 12th goal of the season past Sharks goaltender Alexandar Georgiev as Habs’ Christian Dvorak lurks on the far side.

Samuel Montembeault was solid in goal, stopping 27 of the 30 shots he faced, including two huge saves on Macklin Celebrini from in close on a power play with just over five minutes left in the third period. Armia would score the winning goal just over a minute later.

Owen Beck, who scored three goals Monday during the AHL All-Star Challenge in Palm Desert, Calif., took Michael Pezzetta’s spot in the lineup against the Sharks and had a strong game with Christian Dvorak and Gallagher as his linemates. Beck, who turned 21 on Monday, has 11-16-27 totals in 41 games this season as an AHL rookie with the Laval Rocket. The game in San Jose was Beck’s third with the Canadiens this season and also his best as he tried to fill the void left by Heineman.

“Trying to bring energy to the group, make things happen on the forecheck and allow my linemates some space to create offence,” the 6-foot, 199-pound Beck told reporters in San Jose after the game. “I focused a lot on putting on some weight in the summer to play pro hockey and just being able to use it tonight to my advantage was good.”

Head coach Martin St. Louis was impressed.

“I told Owen Beck he played an excellent game,” St. Louis told reporters in San Jose. “He was very visible, very direct in his physical actions. He had good touches, he had chances to score. He brought a lot to that line.”

The win was the 100th of St. Louis’s career as head coach of the Canadiens, improving his record to 100-123-31.

St. Louis wasn’t happy with the way his team’s game had fallen off during the five-game losing streak. He noted that the execution level had dropped and players were starting to lose confidence.

“I think when we were going good it was all about the details and being sharp for the collective game and I feel everybody individually felt good because they benefited from that because the game was easier to play,” he told reporters in San Jose after practice Monday. “We were connected and when the game is easier to play the players will benefit from that and then they’re confident. We’re not far off, but we’re finding ways to lose.”

St. Louis wasn’t happy with the effort level from some players and decided to bench forwards Patrik Laine and Kirby Dach for most of the third period of Sunday’s 3-2 loss to the Ducks in Anaheim.

“I felt that line (with Laine, Dach and Alex Newhook) was not doing enough on both sides of the ice,” St. Louis said. “You have to follow your gut as a coach during a game and that’s what I did.”

St. Louis mixed up his lines against the Sharks, dropping Laine to the third line with Evans and Armia while moving Josh Anderson up to play with Dach and Newhook. After going pointless in the previous four games, Dach had two assists.

After finding ways to lose during their five-game slump, the Canadiens finally found a way to win.

“The effort was there,” St. Louis told reporters in San Jose. “We competed tonight. Nothing is perfect, but it’s exactly what we needed was the two points.”