Terminate also pending instances.

Added logic to terminate pending instances, and fixed wrong timeout math.
Addresses comments in pull.
Let's stop instances only if we run in the cloud.
Merge pull request #389 from obino/AC_wait_timeout

Terminate also pending instances.