Fix issue #586

If a stub throws an exception the `invoking` flag should be deleted, so the stub can be reset without throwing an error.