Controlling Neural Collapse Enhances Out-of-Distribution Detection and Transfer Learning