Intended way of shutting down resources


i struggle how to shut down resources which i need during my scenario. According to the documentation i should use “before” and “after” methods.

Let’s imagine that i create a ssh proxy tunnel with my “before” method and the scenario action itself will create a TCP connection towards my tunnel. If i look at the kafka gatling extension, the extension registers the shutdown of the TCP connection within the ActionBuilder with the akka system shutdown:

What is the architectural intended way for this scenario, because the “after” method will always get executed first and then the TCP connection will get closed with the shutdown of the scenario. Since the connection is already gone, this will throw an exception.

Is the Kafka extension doing it wrong or on the wrong location (e.g. like this:
Is there any known way how to get the ActorSystem within my scenario, so i’m able to register shutdown methods there as well?

Best Regards