Fix #370

Check that the child is not undefined before trying to kill