Outgoing New Zealand head coach Steve Hansen warned the rest of the rugby world to expect a backlash from the dethroned Rugby World Cup champions over the next four years, after leading the All Blacks to a third-place finish on Friday night.

New Zealand beat Wales 40-17 in the bronze-medal match at Tokyo Stadium, having failed to reach the final after a devastating 19-7 defeat to England in the semifinals in Yokohama last weekend.

The All Blacks had known practically nothing but success during Hansen's eight years as head coach, winning the World Cup in 2015 and racking up a world-record 18-match winning streak from August 2015 to November 2016.

But Hansen warned the rest of the world that "it's now personal" for the All Blacks after losing their crown in Japan, even if he will not be around to oversee it.

"Our challenge is now to regroup and reset the goals for the next four years," said Hansen, who had already announced before the tournament that he was stepping down. "However, what I do know is that the young men that are going to come back have a personal pain. They've experienced something that you can't tell them about, you can't convince them about until it's personal to themselves. And it's now personal.

"So that will make them a little bit more dangerous. I look forward to seeing them grow and continue to grow. And I look forward to the game doing the same thing, because the more competitive it is, the greater it is for the game."

Hansen was joined in calling time on his All Black career after Friday's game by captain Kieran Read and his teammates Ben Smith, Sonny Bill Williams, Ryan Crotty and Matt Todd.

Read leaves with 126 caps to his name — 52 as captain — and the 34-year-old was given the honor of leading the haka before the game.

"It's been a great day," said Read, who is second on the list of New Zealand's longest-serving captains behind Richie McCaw, who led the All Blacks 110 times. "I've tried to make sure I really stay in the moment and actually enjoy this day. I think my emotions at the start of the week, I was able to get them all out of there, so today I was just pretty much about process. I wanted to come out and play well and soak it up and enjoy the occasion. That's what I did.

"I just love playing with this team and my teammates. And then at the end you've got your family to come on and share a bit of the special moment. It was great. I will hold these memories for a long time. I'm going to look back in terms of this World Cup, it's going to take a little bit of time to get over, but certainly in the end I'll come back with some fond memories and remember today as well."

Wales, which lost its semifinal against South Africa 19-16 after Handre Pollard kicked a penalty with four minutes to go, was also bidding farewell to its head coach, with Warren Gatland bowing out after 12 years at the helm.

Gatland turned Wales' fortunes around following a first-round exit from 2007 World Cup, winning four Six Nations Championships — including three Grand Slams — and reaching two World Cup semifinals as well as leading the team to the top of the world rankings earlier this year.

Gatland will be succeeded by fellow New Zealander Wayne Pivac, and the outgoing head coach urged his successor to keep up the high standards.

"I think I had already gone through that process of knowing it was my last game and not trying to be too emotional about it," said Gatland, who will now join New Zealand's Chiefs on a four-year contract, with a sabbatical to coach the British and Irish Lions on their tour of South Africa in 2021. "I had come to a realization a while ago and it's something I had prepared myself for, and then to start thinking about the next challenges in life.

"I really hope for what we have achieved in the last 10 or 12 years, and we feel like we've earned and put respect back into Wales as an international team, that the new coaches come in and continue to build on that. Because with what we've achieved, it would break my heart if Wales went back into the doldrums."

Wales arrived in Japan with several young players on its squad, and No. 8 Ross Moriarty believes the team will be well equipped to deal with the new era now that Gatland has departed.

"We've got a good crop of players and young boys," said Moriarty. "Sadly, we will probably see a few of the older boys go, and they've been great with everyone. They've set the foundations for what's to come.

"It's been a lot of hard work. We're disappointed not to be in the final but hats off to New Zealand — they played some good rugby but so did we today. We kept it at 12-7 in the second half, and I know that's still not a win but we can hold our heads up high and look forward to the next season in the Welsh shirt."