Ideally, I'd go to one of the top 4 departments: Stanford, MIT, Berkeley, CMU. Graduates of top universities with decent skills don't have a hard time finding jobs. I'll probably add Columbia and Harvard (middling departments, strong lay prestige) as (irony here) "safety schools". A quant fund isn't going to know the difference between a Harvard CS PhD and one from MIT (or might put Harvard higher).
Anything below the top 20 (and it's top 10 in the rest of STEM and top 1-2 in humanities) has to be purely for the education, though. You're right that a #40 PhD, while the educational program is probably fine, won't fix your career.
Also, the academic job market is terrible and that does not change if you have a PhD from an elite department. That's not what I'm aiming for.