Motherwell have confirmed that forward James McFadden will leave the club when his contract expires at the end of May.