Clarify error scope and create variable for deferring cleanup Signed-off-by: Derek McGowan <derek@mcg.dev>