After more than 150 years of housing mentally ill patients, Taunton State Hospital will close its doors, and its remaining patients will be sent to other facilities by the end of the year, state officials said yesterday.