properly close CLIWrapper in finally block