Here's how Optimus leaves Earth and the end of the film goes in Brian and the Eeveelution Family's Adventures of Transformers: Age of Extinction.
[Optimus lands on a helicopter platform]
[Cade and Tesaa embrace]
Cade: Kind of nice being your hero for a change.
Tesa: You always were. All my life.
Cade: I love you.
Tesa: I love you, too.
Cade: Let's go home to graduation, huh?
Cade: [to Shane] You're okay, kid. Come here, you're all right, all right.
[They all hugged, then Joyce walks up]
Tessa: We don't have a home, dad. It blew up.
Joyce: I might be able to help you with that.
[Cade and Joyce hugged]
[Bumblebee drives up]
Optimus: Brave warriors.... you are free!
[The Dinobots transform]
Cross-Hairs: I'll ride with you anytime, Spike!
Grimlock: ROAR!!!!! [he takes off with the other Dinobots]
Duck: [giggles] I like those robot Dinosaurs!
[Su Yueming runs up]
Joyce: Did you miss me?
Su Yueming: No.
Optimus: This Seed belongs to our creators, whoever they are. There remains a price on my head. I endanger you all if I stay. [he wields the Seed] I shall take it where it could never be found.
Cade: Will we ever see you again?
Optimus: Cade Yeager, I do not know. But whenever you look to the stars, think one of them. As my soul. Defends this family, Autobots, as they have you. Defend. All they can be.
Sylveon: But Optimus. It sounds like your never gonna come back.
Optimus: I might not, Sylveon. But I can't let Earth be in danger more from my creators, and I can't let anyone else use the Seed to create a new Decepticon army. And you know.
Sylveon: Yes, I know.
Optimus: But I sense that I see one of you as Prime like me.
Lois: Well, me, and the others never been involved with your first three adventures.
Optimus: Lois, I am proud of you. That you have changed your ways with us, and I know you have a good heart. That's what all mothers have, like Sylveon she takes care of Eevee, and his siblings, along with Brian. While you take care of your kids, along with Peter. And even Cleveland and Joe do the same with their families.
Quagmire: Well, I'm still searching for the perfect girl, Optimus.
Optimus: [chuckles] Of course you are, Quagmire. And I hope someday you will find the perfect girl, and raise a perfect family. Now, I must go. While you all protect my family.
Brian: Optimus, we're gonna miss you.
Optimus: And I will miss you too, Brian. But if I return one day, we will have more adventures together. With new friends, and new enemies. But now, I must go.
Brian: [starts weiding up tears] Then if that's the case, may the Force be with you.
Optimus: And you. [gets ready for take off]
Brian: [voice breaking] Goodbye, Optimus.
Optimus: [starts his rockets and takes off and he begins sending a message] There are mysterious to the universe we were never meant to solve. But who we are and why we are here. Are not among them. Those answers we carry inside. I am Optimus Prime and this message is to my creators: "Leave planet Earth alone. Cause I'm coming for you."
[It cuts back to Patchy]
Patchy: Ahoy, children! I'm back! I hope all you boys and girls enjoyed the movie, because it's time for you to walk the plank! [Screen reads: PLEASE STAND BY] Oh, sorry, kids. What I meant to say because it's time for fan mail! [blows horn]
Old-time crowd: Hooray!
Patchy: And now, the moment you've all been waiting for, so get ready to blow milk out of your nose because we're gonna open a letter! [Potty flies to Patchy with the letter and he has a lighten fuse on his head] The envelope please Potty. Thank you, my fine feathered assistant.
Potty: Brawk, you're not welcome.
Patchy: [Patchy blows his nose] Hey, Potty, do you smell something? [notices the fuse] Oh, Potty! That fuse in your head! I told you we're not doing that stunt!
Potty: Brawk, I didn't get the memo! Brawk! [Potty blows up along with Patchy; Patchy coughs up a feather and recovers from the blast]
Patchy: Well, thanks for watching "Brian and the Eeveelution Family's Adventures of Transformers: Age of Extinction". Hooray! [Potty collapses to the floor]
[The movie ends with "One More Light" playing in the background. And in the last shot, it shows a picture of Chester Bennington, saying: In Loving Memory of Chester Benninton. March 20, 1976 - July 20, 2017. And it fades out to black]