Fix stream close method