Properness of K-moduli spaces