Prevent handle leak in error path