Wall Street ended a stunning second quarter quietly today as fund managers spent the day repositioning their holdings, but the narrow losses didn’t stop the Standard & Poor’s 500 index from achieving its best quarterly gain since the final three months of 1998.