Kill instance of salome when running in TUI [killSalome]

Hello,
when running a script in TUI by “salome -t script.py” if we want to kill salome after the script is finished,
I normally added at the end of the script

import killSalome
killSalome.killAllPorts()

but this will kill all the instances of salome if I am correctly, so if we are running multiple scripts in the background it will be problematic, is there any way to kill the actual instance?
i found “killSalome.killMyPort” and tried to use

import killSalome
killSalome.killMyPort()

without succes, as the instance stills runs. any solution for this?
EDIT:
it looks that this workaround solves the problem I was having, by adding at the end of the script:

import killSalome os
killSalome.killMyPort(os.getenv('NSPORT'))

best regards,
F.