It is important that the script you're invoking always will terminate on its own. NiFi cannot reliably kill threads that it has handed out to components. The community has a feature in progress which will provide a solution to work around these cases but the real solution is to ensure that the invoked stream command always terminates properly.