TD Bank is closing 38 branches, including six of its stores in Massachusetts.