Treatment works are allowed to release sewage into waterways after heavy rain to stop it backing up.