Properly wait for command execute finish