Disposing of session-related resource


I am writing a Gatling plugin for a custom protocol that uses a thick client.
Said client is not thread-safe, so I want to bind it to user’s Session.
Basically, when the Action is invoked, the Session is inspected and the thick client is created and bound to Session if it is not present.

Right now I am registering the said thick client’s shutdown with coreComponents.actorSystem.registerOnTermination, but this means that the clients are not closed until end of simulation.
Is there any API I could use to make sure that consumer gets closed when the Session is no longer in use?

Gatling version is 3.3.1.

Yours sincerely,
Adam Kotwasinski