Yoga Sutras 3.56
Patanjali, explained by Swami Vivekananda
सत्त्वपुरुषयोः शुद्धिसाम्ये कैवल्यमिति ॥
sattvapuruṣayoḥ śuddhisāmye kaivalyamiti
By the similarity of purity between the Sattva and the Purusha comes Kaivalya.
In plain words: Kaivalya means complete freedom, when the soul knows it depends on nothing at all. It comes when the thinking mind (Sattva) becomes as pure as the true Self (Purusha). Then the mind simply reflects that pure Self.
Swami Vivekananda explains
When the soul realises that it depends on nothing in the universe, from gods to the lowest atom, that is called Kaivalya (isolation) and perfection. It is attained when this mixture of purity and impurity called Sattva (intellect) has been made as pure as the Purusha itself; then the Sattva reflects only the unqualified essence of purity, which is the Purusha.