Chaos near structural phase transitions