Dr.Monzer Kahf, a prominent economist and counselor states: “A muslim that has shares from a non-Islamic bank is advised to just sell them and if they made any capital gain or get any dividends they should give that away to Muslim charities or Muslim poor and needy. They may recover their principal only.
Besides we have Verse 11:114 that says “Indeed good deeds wipe out bad deeds. Keep doing Istighfar, Prayers, Du’aa’, and charity. That will clear all bad deeds In ShaAllah.”