Purification on stock that becomes Shariah non-complaint

Can help to provide guidance and reference on how to purify the gains accumulated in a stock bought a few years ago when it was shariah compliant and turned to non compliant over the period of time?