Disposing of session-related resource

Hello,

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

https://github.com/gatling/gatling/blob/master/gatling-core/src/main/scala/io/gatling/core/protocol/Protocol.scala#L49