WeWork said Thursday that it was going to close roughly 40 “underperforming” locations in the United States and tempered its revenue forecast for the year, highlighting the challenges the co-working company still faces after its near collapse and subsequent bailout in 2019.