Prevent phantom user hooks
Prevent phantom user hooks

Clear an active user hook when an exit exception occurs (e.g. the thread is
cancelled). Previously we only caught Exception so exit exceptions were
excluded.

To also cover the case of an unclean exit (e.g. kill -9), don't wait on a
hook that is left over from some previous stack operation - only start the
hook if it is set in the current environment.

Change-Id: Ie894f416a898edeca3b6a123392853213893ff74
Closes-Bug: #1538733

dims/heat,jasondunsmore/heat,openstack/heat,steveb/heat,dims/heat,cwolferh/heat-scratch,cwolferh/heat-scratch,noironetworks/heat,noironetworks/heat,jasondunsmore/heat,steveb/heat,openstack/heat