This is how Optimus and Wheeljack return and the Unicron trap goes in Thomas' Adventures of Transformers Prime Beast Hunters: Predacons Rising.
Unicron: What? A familiar resonance pure energy, not unlike Primus... one I have not encountered since ancient days. The Allspark!
Bumblebee: Optimus and Twilight.
Knock Out: I never thought I'd be so happy to see that big rig and that lavender Alicorn!
Optimus Prime: We must keep the Allspark from Unicron's reach.
Wheeljack: I thought the container was indestructible.
Twilight Sparkle: Indeed. But if this vessel once trapped the Allspark, Optimus and I fear that it can also be emptied of it.
Unicron: So, the Prime and the Princess return!
Thomas: Ugh! Ugh!
Unicron: Thank you, Prime and Twilight. For delivering the Allspark so that I may erase it from existence.
Optimus Prime: Not while Twilight and I stand before you, Unicron. Megatron, you, Twilight, and I once united to save a world from Unicron. We must do so again.
Unicron: Megatron may hear you, but he cannot help you. For he is enduring eternal suffering. Your efforts to protect Cybertron's most sacred relic are futile! My legion is within reach of Primus, your planet's very core. And we both know that the Allspark cannot thrive in a poisoned well.
[The team move on]
Knock Out: Downside to wearing metal near a Polarity Gauntlet...
Thomas: You're subject to the laws of magnetism.
Bumblebee: Optimus, Twilight, go! Save the Allspark!
Twilight Sparkle: I've been worse. So, how are we gonna get that thing to safety?
Thomas: By the only means available to us under these most dire of circumstances. The very survival of our species upon this or any world depends upon it.
[Ryan is running with the Allspark Vessel]
Unicron: I shall devour your Allspark whole!
Ryan F-Freeman: [sighs] Okay. Here. You have it.
[Crash stops Unicron by fighting him]
Crash Bandicoot: Megatron! You are being controlled by Unicron! You must fight him! Fight him or you're no better then Ryan or Midnight Sparkle!
Unicron: Megatron might hear you, Keyblade wielding orange Bandicoot. He can't HELP YOU!
[in Megatron's mind, Megatron is screaming in pain]
Unicron: For your enemy is enduring eternal suffering.
Ryan F-Freeman: Unicron the chaos bringer! Why you want the Allspark?
[Crash gets tired]
Unicron: I think this bandicoot is tired, Ryan.
Ryan F-Freeman: Well. Since you got a new body so I give you this as an award for telling Sunset.
Unicron: I think that's nice, Ryan.
[Ryan chuckles as he gives Unicron the Allspark vessel. When it opens up, it's empty]
Unicron: What?! A trick?!
Ryan F-Freeman: April Fools!
[Unicron's energy form gets sucked into the Allspark Vessel and the Dark Energon within Cadance gets sucked out into space and the Terrorcons turn to dust. Ryan looks at the Allspark vessel]
Ryan F-Freeman: Rust in peace, Unicron.
Crash Bandicoot: Uh... Don't you mean "rest", Ryan?
Matau T. Monkey: Master Ryan? How did you do?
[Unicron screams in pain]
Ryan F-Freeman: Pretty good.
Matau T. Monkey: We did get some new allies for this. The Elements of Insanity, the Autofruit and created some two heroes. Who are they called?
Ryan F-Freeman: Uh, Brutan Sparkman and Codset Shimmerbrother.
Penn Zero: My friends and I came as soon as we got your call.
Ryan F-Freeman: Penn Zero. You got here. And you're... you're...
Crash Bandicoot: Late?
Penn Zero: No.
Matau T. Monkey: If that's what I know that Megatron might be dead.
Penn Zero: Anyways, Ryan, as you were saying?
Ryan F-Freeman: Oh, yeah. You're in your Massive Morphy Merge Mech forms.
Evil Ryan: How did he got to Cybertron? If you star in Crash, Thomas and Ryan Meets the Swan Princess, Penn. Twilight will help Ryan and the blonde hair princess. I don't know her name.
Penn Zero: Seen it before. Totally remember the name: Odette.
Crash Bandicoot: I hope Twilight emptied the Allspark into the Matrix and not anything else.
Twilight Sparkle: Sorry, Crash, but some of the AllSpark was emptied into my horn. The rest is in the Matrix.
Ryan F-Freeman: What?! You think I can get this out of you?
Twilight Sparkle: No. Optimus and I need to merge with Primus.
Ryan F-Freeman: If you do, I'll be alone like Sunset. How is that I'm not one with the Allspark? Including Evil me?
Twilight Sparkle: You're a techno-organic. Techno-organics can't join the AllSpark. And Evil Ryan has Unicron's life-blood in him. And you will not be alone. You have the others.
Ryan F-Freeman: Dark Energon. Twilight. I'm not going to lie to you but...[starts crying] I'm going to miss you when you die.
Evil Ryan: Let's not get episodic here, Ryan. How did Twilight got some of the Allspark into her horn?
Ryan F-Freeman: I don't know. Can Twilight still use her magic?
Twilight Sparkle: I'm gonna tell you how some of the Allspark got into my horn.
[flashback during the final battle with Unicron, Optimus Prime walks over to Twilight, about to empty half of the Allspark into Twilight's horn but stops to tell her something]
Optimus Prime: Twilight. There's something I have to tell you.
Twilight Sparkle: What?
Optimus Prime: The Allspark is about to be erased by Unicron. You and I must empty it into the Matrix and your horn to prevent that from happening. And the reason why I asked you to come with me was that I wanted to test your capabilities as a Prime.
Twilight Sparkle: That's the reason? Why didn't you tell me this earlier?
Optimus Prime: Because, Ryan would think I was crazy.
Twilight Sparkle: Okay. But I don't think so.
Optimus Prime: You mean everything to me, Twilight. You would've made a great partner for me.
Twilight Sparkle: You haven't said that to me in such a long time.
Optimus Prime: Are you ready to have the Allspark in your horn?
Twilight Sparkle: Yes.
[Optimus then empties half of the Allspark into Twilight's horn and then empties the rest into the Matrix]
Evil Ryan: That's new. You think I can use my magic and transfer the Allspark to Ryan?
Ryan F-Freeman: What!? Me having half of the Allspark?! That's crazy talk. I was a records clerk like you back in Equestria.
Optimus Prime: No, Evil Ryan. The Allspark is intransferable.
Ryan F-Freeman: In other words, you can't put the Allspark in me.
Ryan F-Freeman: I hope you will come back in your body, Twilight. I have to tell you that I too was a records clerk like Optimus and you.
Twilight Sparkle: I already figured that out. And don't worry, I will come back one day.
Crash Bandicoot: So, you would come back on Earth as yourself rather then on Cybertron. I have to live with that.
Ryan F-Freeman: Is there a photo I could have to help me and Thomas remember you?
[Twilight nods and gives Ryan a photo of Ryan, herself and their friends]
Ryan F-Freeman: Thanks. While looking in the Hall of Records of Iacon, I manage to get info on how Optimus became a Prime.
Evil Ryan: Whoa. Twilight? I hope that if you want to see me again, I'll be at CHS.
Ryan F-Freeman: In the meantime. Twilight. Let me tell you a tale. Long ago in Cybertron. Optimus and Megatron were not always enemies.
Twilight Sparkle: Optimus already told me.
Ryan F-Freeman: He did? At least I'm proud of you. Unicron told me his story.
Evil Ryan: Twilight? How did you do with Optimus? Ryan fought Unicron and saved his friends and your sister-in-law. A little test to see Ryan has got what it takes to be a Prime.
Twilight Sparkle: Thank you, Ryan. [hugs Ryan]
Bertram T. Monkey: Twilight. These stories are nothing like this one. Let me tell ya. In ancient times, people believed that the light was a gift from an unseen world by the name of Kingdom Hearts. But, Kingdom Hearts was protected by it's counterpart, the χ-blade. Warriors wanted that precious light. That started a thing called the Keyblade War. One violent clash broke the χ-blade into 20 pieces. Seven of light and 13 of darkness. And the only real Kingdom Hearts was consumed by the darkness, never to be seen again. My master, Xehanort, once tried to make his own pure light and the darkness to forge the χ-blade, but the attempt ended in failure. In my master's eagerness, he had loss sight of the right way to complete his goal. He acted rashly. I admit it now.
Ryan F-Freeman: Wow. Cool story, Bertram.
Twilight Sparkle: Bertram? You think in that story, your master's mistakes changed the destinies of three friends?
Bertram T. Monkey: Yes, Twilight. But destiny is never left to chance. He guided them to their places in their roles. The broken boy who failed to be the blade, the girl with the blue hair who sacrificed herself for a friend and the young man who became my master's new vessel.
Crash Bandicoot: Who are those three, Bertram?
Bertram T. Monkey: Ventus, Terra and Aqua. I just want you to believe that their sacrifice stopped him for good.