Also, Optimus Prime is ruined. He executes a Decepticon! Optimus Prime does not execute. He expressed regret over defeating Megatron in the first movie.
Yes, but ultimately he is a warrior, however noble. This is war, and letting Demolishor go rolling around China would have meant more humans hurt/killed and that was unacceptable. In war, you make harsh choices and killing your enemy is among them. And it's not like he just tied the guy up and blew his head off. Demolishor did a fair bit of killing and smashing himself before they caught up to him.
This is also consistent with his portrayal in the original series. Never mind the series (where few consequences of battles were ever shown) but in the 1986 movie Prime was ready to execute Megatron despite his pleas for mercy.