How to Forcefully terminate a Gatling Simulation after certain defined period when there are multiple dependent gatling simulation running

Below is my Gatling Scala code where I am running two simulations: importSimulation and retrieveSimulation.

Currently, importSimulation runs for 3 minutes but continues to execute until all requests are completed, which can take 5 to 6 minutes. As a result, retrieveSimulation gets very little time to run because the total maximum duration for both scenarios is set to 7 minutes.

I want importSimulation to run with 300 concurrent users for exactly 3 minutes and then force stop. After that, the next simulation, retrieveSimulation, should be triggered. How can I achieve this?

setUp(
  importSimulation.inject(constantConcurrentUsers(300).during(3.minutes))
    .andThen(
      retrieveSimulation.inject(constantConcurrentUsers(PerfConfiguration.concurrency).during(4.minutes))
    )
)
  .assertions(
    global.successfulRequests.percent.is(100)
  )
  .protocols(httpProtocol).maxDuration(7.minutes)

Hello Vishesh,

I see that you use a close model, can you explain your use case?