Still trying to get it to terminate properly