close reader first if not null.