If you are attempting to terminate Runtime essentially after a case fails because of invalid credentials, there is a better way. Each adapter has a property named "ReadyForRobotWork" (and a corresponding property called "ReasonAdapterNotReady"). Use this property to tell Robot Manager that your bot is not ready. For example; default this property to False. On Startup, login to all of our applications to test the credentials. If they are valid, then set this property to True. If not, set the "ReasonAdapterNotReady" property to your message which will make this visible in Robot Manager.
If you'd rather test the credentials during case processing, then I would simply set the property to false once you know the credentials have failed. Finish your case as planned and terminate Runtime after calling SetCompletionStatus. In my experience, calling TerminateRuntime should finalize everything, so there might be something we'd need to see in your RuntimeLogs. As a workaround, once you've set the "ReadyForRobotWork" to false, you might try pausing for a bit before calling TerminateRuntime to allow for the SetCompletionSTatus to complete, but I don't believe that is necessary.
Hi, we tried using the solution (second paragraph) that you have provided but still the case status is still empty after termination. We tried to set the "ReadyForRobotWork" to false and pass an error description to "ReasonAdapterNotReady" then update the case status before using the TerminateRuntime.