Ukraine wasnt "kept out". They just hadnt progressed to full membership yet.
NATO had already expressed its desire quite clearly both in Bucharest in 2008 and in Brussels in 2021 to put and keep Ukraine on the path to full membership.
Putin's gamble is that reducing the country to rubble now makes it unviable as a member and hence lowers the likelihood of him ending up like Gadaffi and Russia ending up like Libya.
It could backfire and it may be the worst gamble anybody ever made but it's not irrational.
Putin ending up like Gadaffi and Russia like Libya was never going to happen, because Russia has nukes. Just like the US hasn't taken out the Pakistani government despite them literally harbouring Osama Bin Laden.
NATO had already expressed its desire quite clearly both in Bucharest in 2008 and in Brussels in 2021 to put and keep Ukraine on the path to full membership.
Putin's gamble is that reducing the country to rubble now makes it unviable as a member and hence lowers the likelihood of him ending up like Gadaffi and Russia ending up like Libya.
It could backfire and it may be the worst gamble anybody ever made but it's not irrational.