Fix issue where loader would not close external processes, leading to too many processes running and resource exhaustion