To prevent the black from doing Ng6. Doesn't quite do it though but is daunting. Ng6 Nf5+ Kh8 (Kg8 loses a rook) looks playable for black.
18... Kg7h8
and the defense holds.
19. g4 Ra8e8 20. Kc1d2
?! the king is the last piece I have that is not already committed to the attack. Bringing it in only exposes it to a counter-attack but I could see nothing better.