Optimal control of systems governed by differential equations with applications in air traffic management and systems biology