I've had this same problem as well. Try saving your game. Exit game, and then restart. I did this and he finally put down his sword, looked around, and left. Hopefully this helps.
I had the same bug. You need to squeeze up to him like you're trying to push him away. Then while you're both squeezed, save and exit. Once you load up again, he'll return to Riverwood.