For some reason this does not work:
$category->setIsActive(false);
You must use this instead:
$category->setIsActive(0);