Added explicit close function for command workflow.