As an immediate goal – maybe, but how connected these things are? It's not like Ukraine getting paid their transit tariffs actively funds the war.
Also, would the war stop if Ukraine takes a nuclear option and blows up the pipeline? Unlikely, I'd say. But that's a good way to jeopardize the future in N years, throwing away economic and political leverage like that. The war would go away – but so would the income and power.