save stdout/stderr even if an exception occurrs