U.S. stocks closed lower on Friday as technology and AI-linked shares led the selloff, while energy and defensive sectors outperformed.