The Green Line’s D branch, which runs to Riverside in Newton, will close for two separate nine-day periods in the next month to accommodate work along the line.