Ego exists because of doership of whatever good or bad one does in life. Ego remains in the foundation unless one comes out of their so called existence(Name) and remain in pure Soul (your true Self). After one attains Self-Realization, only then one can remain in their true Self.