Refactor CLI to use promise API and manually disconnect