Thanks to the Rook Gambit, the rook isn't on a8, offering this very beneficial tactic. With tempo, as the knight is being attacked.
18. Qb6b2 Bd5xg2 19. Rf1e1 Bg2h1
This threatens Qf2++. Note that there is no white square bishop due to the earlier Rook Gambit exchange, thereby contributing further to black's position.
20. Ne2f4
This is the only way to stop mate.
20... g5
A rook down, black bravely no longer cares about even such trifles as the solidity of his king's castle.
21. Qb2e2 gxf4 22. f3
If Qg4+, Kh8, then soon Rf8 is to follow. The pawn move temporarily obstructs the bishop's protection.
22... Bh1xf3
The pawn isn't safe.
23. Qe2f2 Bf3h1
Still plotting Rf8. But also possible is Bh4, and if Qxh4 then Qg7++. And if queen moves, then bishop wins the rook.
24. Kg1f1
With two imminent threats, it's a good idea to move the king away from the danger zone.
24... Be7h4
Still can't take in this situation because of Qg2++.