Reset $stdout correctly when block raises an error