US stocks close Thursday with gains as oil prices down