In MANY countries, including the US and many European ones, leaving the country at time of war would be considered desertion, and punished with long prison terms. One wouldn't be denied consular services; one would be arrested on the spot.
The Ukrainian government is so nice it's downright populist.