If he knows that the company is going to take a riba-based loan, when should he sell his shares?
Question

If a person knows that the company is going to take a riba-based loan, when should he sell his shares?.
Praise be to Allah.The one who wants to buy shares in any company should make sure that its activities, sources and products are halaal, because it is not permissible to buy shares in a company whose activities are haraam, such as riba, gambling, prostitution and the like. It is also not permissible to buy shares in a company whose activities are permissible but it lends or borrows money on the basis of riba, because shares are part of the company’s wealth, and the shareholder is a partner in all the transactions that go on, and the administration runs the affairs of the company as a partner and as a deputy acting on behalf of the other shareholders. 
What is meant that the sin of any haraam action, such as borrowing money on the basis of riba, is borne by the shareholder on the basis that he is one of the partners. Hence he is obliged to denounce that and leave the company if it insists on engaging in haraam transactions. 
In the case asked about here, it is permissible for the shareholder to remain with the company, until he is certain that the company is taking loans that are based on riba, at which point he should sell his shares.  
Every Muslim who is keen to avoid riba and its consequences should make his position clear to the company, and state that he will leave if the company takes a riba-based loan. He should broadcast that and make it well known so that he will free himself of any blame, and so as to advise those who are in charge of the company in the hope that he may persuade them to change their minds about the decision to take a haraam loan. It is well known that some Islamic banks can offer suitable cash flow to these companies by means of permissible, sharee’ah-compliant contracts, so there is no need for the haraam options. 
We only say that he should sell his shares when he is certain that the company is going to take a riba-based loan, because staying with the company after that is a kind of helping them to do what they want. If he and other good people leave them, this will serve as a reminder and advice to the company, as stated above. 
As for his staying until the loan is actually taken, this is taking part in the haraam riba-based contract, and the Prophet (peace and blessings of Allaah be upon him) cursed the one who consumes riba and the one who pays it, the one who writes it down and the two who witness it, and he said: they are all the same.
Narrated by Muslim (1598) from the hadeeth of Jaabir (may Allaah be pleased with him). 
We put the following question to Dr Muhammad al-‘Usaymi (may Allaah preserve him): He bought shares, then he found out that the company was going to take a riba-based loan. Does he have to sell them now, or when the company actually takes the loan, or just before that if he knows when it is going to happen? 
He replied: It is better to do it before the loan is taken out, and it is obligatory once the loan is actually taken out, unless he will lose thereby, in which case he should wait until he can regain his capital. And Allaah knows best. End quote. 
And Allaah knows best.