US stocks close flat with Nasdaq, S&P ending week lower