This situation is called ' checkmate '. You are writing about one of the possible outcomes of the game. And it's impossible to solve chess as it's very complex.
I have 'solved" chess

It's not a complete solution, but it's a good idea when practical.
I think Fred Wilson, in Simple Attacking Plans, has similar but clearer advice: point all of your pieces as practical at your opponent's king and relentlessly attack.

Kyle Larson is the best NASCAR driver
My favorites right now are Kevin Harvick and Kyle Larson. Nice that we like the same racer. Do you like Harvick as well?
Control the ranks,files,and diagonals your foe's King is on and adjacent to.