Fixed close logic error.