Foreign investors pulled a record amount of money from China last quarter, likely reflecting deep pessimism about the world’s second-largest economy.