On properness of K-moduli spaces and optimal degenerations of Fano varieties