Some states including Indiana, Kansas, Louisiana, Kentucky, Maine, New Mexico, and Oklahoma allow students to drop out of school at age 17 so yes you can legally leave school grounds at age 18 because you're an adult at 18.
You don't legally have to attend school at age 18 unless you want too in most states.