Tim Cahill has left New York Red Bulls and joined Chinese club Shanghai Shenhua after turning down an offer to rejoin David Moyes at Real Sociedad.