Minor refactoring.
Call chunk close with chunkIdx.