Fixed assert on close.