Bug fix on closing.