Change variable name and fix bug.

The `thrown` is used to mark whether or not a exception be thrown. If no exception thrown, checks the process of `close`.