Wait for commands to finish