Chipmaker TSMC has agreed to stop expansion of a plant in northern Taiwan following protests from local residents.