Fighting the corruption and lack of religious tolerance that bred such groups in the first place
ISIS is made up of fighters who rightly or wrong have been indoctrinated into viewing the situation of their country as a situation of religious persecution. Even though their caliphate has now fallen, and they have now been made refugees, these people will continue to feel this religious persecution and will go on fighting or feeling prepared to until they are un-indoctrinated somehow, or the dismal situation of religious intolerance is addressed. Refugees should be confined to their geographical location as much as possible, to not let memories of the Islamic state caliphate spread and develop in any way. But ultimately establishing peace and religious tolerance in the regions affected by this violence and unrest will have to be the long term goal, those from other regions should be permitted to return their country of origin to stand trial or allowed to stay.