Clean up session after command completion or teardown
Change API so that print does not involve passing pointers