A: First,
you should repent and ask Allah (Exalted be He) for forgiveness for having contributed in such a forbidden deed, and resolve not to return to it. Moreover, you have to withdraw the value of your shares in such banks that Allah (Exalted be He) may forgive you, for He (Glorified be He) says:
And verily, I am indeed forgiving to him who repents, believes (in My Oneness, and associates none in worship with Me) and does righteous good deeds, and then remains constant in doing them, (till his death).
Second,
you should get rid of
the profit you gained as a result of this business and spend it on the poor and needy. (Part No. 14; Page No. 49) May Allah grant us success. May peace and blessings be upon our Prophet Muhammad, his family, and Companions.