A Dynamic Optimization Approach for Wide-Area Control of Transient Phenomena