Tim Allen apparently warned Tom Hanks about the “tough” ending of “Toy Story 4” before the actor recorded his part.

Hanks, who has voiced Woody from the “Toy Story” franchise since it began in 1995, appeared on “The Ellen DeGeneres Show” Wednesday to talk about the newest installment, which is set to hit theaters on June 21.

KEANU REEVES’ ‘TOY STORY 4’ CHARACTER, DUKE CABOOM, REVEALED IN NEW TRAILER

“It’s about the most rewarding thing I could imagine have being a part of because it just has gone on for so long,” Hanks said about the 25-year span of the franchise.

He also admitted his one hang-up with the films, explaining that while he was recording, there were only producers and writers in the room watching him.

“It was making me self-conscious so for the last couple of sessions I turned my back on those punks and did it without them,” he said.

“Also because this is the end of the series and I had gotten some texts from Tim, Tim Allen, who plays Buzz Lightyear, the astronaut and these texts are saying, ‘Have you recorded yet? Have you been in? Have you had a session yet?'” the 62-year-old “Forrest Gump” star said, impersonating his co-star in a deep voice.

Hanks said that since he hadn’t seen the pages, Allen warned him: “Wait until you see those last pages. Tough one, tough one.”

“And it was,” he confirmed to Ellen. “The last few sessions were -- we’re saying goodbye to Woody and Buzz and Bonnie’s room and Andy and everybody. It was emotional. So I had to, I had to turn my back on them all.”

TIM ALLEN AND TOM HANKS WERE MOVED TO TEARS MAKING ‘TOY STORY 4’

In February, Allen told Entertainment Tonight that he and Hanks could barely hold it together as they recorded the final scenes of the film.

Actor Tim Allen, Buzz Lightyear, actor Tom Hanks and Woody attend the

Tom Hanks, who has voiced Woody from the "Toy Story" franchise since it began in 1995, told Ellen DeGeneres on Wednesday that his co-star Tim Allen, who voices Buzz Lightyear, warned him that the final scenes of "Toy Story 4" were "tough." Hanks and Allen are pictured beside their characters in 1999.
(Getty, File)

"Both Tom and I, who met yesterday for our little guy's lunch, we were both very very affected by the end of the movie," Allen, 65, told the outlet at the time. "So much so that he had turn around. He couldn't even deliver his end of it, [and] I couldn't deliver my end of it."

CLICK HERE FOR THE FOX NEWS APP

"This has been over 20 years of he and I doing this, and it's made an impact on both of our lives our families lives," he added.

“Toy Story 4” also features the voices of Keanu Reeves, Joan Cusack, Tony Hale, Jordan Peele and Keegan-Michael Key. A new trailer for the movie was released Tuesday that included a brief appearance by Reeves’ character, a toy stuntman named Duke Caboom.

Fox News’ Jessica Sager and Stephen Sorace contributed to this report.