You can use the waitToFinish parameter to specify, in milliseconds, how long the stop process must wait before stopping an agent, if the agent is currently serving a request. waitToFinish stops new requests to the agent and waits for the current request to complete. If the current request does not complete in the specified time, a STOP message is sent to the agent.
You can also use the waitAfterStop parameter to specify an additional wait time, in milliseconds. waitAfterStop checks if the agent has indeed stopped. If the agent has not stopped, then a KILL message is sent to the agent at the end of the specified time. In either case, if the agent finishes processing its current request before waitToFinish expires, the agent will immediately shut down.
Note: Both waitToFinish and waitAfterStop are optional parameters. If you do not specify these, the agent will be stopped immediately, irrespective of whether the agent is currently idle or serving a request.