US stocks close with gains amid hopes for continued US-Iran talks