Massachusetts beaches close due to bacteria