State machine for return_items.

Fixes #5041