fix wrong npages when closing