US stocks close with gains to start 2nd half on higher note