what happened to optimus prime at the end of age of extinction
Transformers: Age of Extinction Lockdown returns to capture Optimus and the Dinobots, using a large magnet in his ship that picks up and drops metal objects, causing destruction to the city. After disabling the magnet, Optimus fights Lockdown at an abandoned factory. In the ensuing duel, Optimus kills Attinger (who still angrily deems all Cybertronians aside from Lockdown as a threat) to save Cade, and avenging the deaths of his fellow Autobots. However, this allows Lockdown to pin Optimus down by impaling his chest with his own sword, damaging his spark. Cade, Bumblebee, Tessa, and Shane fight Lockdown, with Cade ending up fighting him one-on-one while Tessa and Shane use a tow truck to free Optimus, who kills Lockdown before using one of his grenades to finish off the remaining drones. Galvatron retreats, vowing to return. As Lockdown's ship leaves Earth, Optimus tells the Autobots to protect the Yeagers (with Joshua offering to help the Yeagers build a new home) and lets the Dinobots go, before flying away into space with the Seed to hide it away, sending a message to the Creators that he is coming for them.