US stocks end mixed to close out worst month of 2023 as investors brace for a government shutdown