Two-time Rugby World Cup winning captain Richie McCaw has retired from rugby and will become a commercial helicopter pilot.