Chelsea FC captain John Terry will leave the club at the end of the season after more than two decades there.