A nuclear test by North Korea unnerved investors, and reports about China’s economy added to concerns that it was slowing.