Improvements to the io and terminal_io backends

Introduce io_setup_t and io_teardown_t for library inititalization and
teardown business. For the terminal io, hide the cursor in the setup and
then show it again on the teardown.