Ukraine was under a 5 year contract for that transit, and their European allies were very insistent that they not break it for some strange reason cough greed cough. Ukraine depends on support from Europe, both in monetary terms and for armaments, but also as a host to millions of Ukrainian refugees.
As soon as Ukraine could legally stop the flow without the EU using the fig leaf of the contract force them to keep it flowing, they stopped it.