I feel terrible for the gorilla. But I also see no other alternative. A powerful tranquilizer would might have made the gorilla violent and unpredictable.
FIFY
As it was, they killed the gorilla anyway because they felt he was unpredictable, but not yet violent. It's possible that a more compassionate approach might have worked also. You can't just discard those options.
As I understand it, the zoo was watching the gorilla for 10 minutes before they decided that the ape was getting more agitated and made the call to shoot. If they had used the sedative immediately the ape may have never gotten to an agitated state. Or other options like ringing the dinner bell and sending in the animal handlers to snatch up the boy might have been an option too.
As it was, the zoo didn't want to take any chances. Which is fine.