Completely not legal. Maybe contract law is bloated enough in the US to give valve that power, I'm pretty sure it isn't in the EU. Valve can't decide how ownership works, not in all jurisdictions.
Worth mentioning that you don't own the games, you buy non-transferable licenses to play the games. Therefore I think it's perfectly (and unfortunately) legal.