[issue #22] Implement error & exception handlers, shutdown functions