As John_P mentioned, it's not enough to call pieceEntry->close() but you have to call swPieceEntry->close().