Former Sinn Féin leader leaves with win and a legal bill that, had case gone the other way, could have seen him facing huge claims