presence of mind

noun

1.
self-control in a crisis; ability to say or do the right thing in an emergency