correctly terminate daemon after testing