Valuative criterion of properness