In a last-minute, out-of-court settlement, Morgan Stanley has agreed to pay up to $54 million to settle claims that the investment bank blocked more than 300 female employees from promotions and bonuses in its institutional equities division, while rewarding lesser-performing men.