Ah, the ending. A bit of a sucker punch for the "we hope D-503 turns out okay" crowd, but nothing unexpected if you know your dystopian fiction. D-503 gets subjected to the operation and transformed into a virtual automaton. Mathematical clarity returns as his humanity is burned out, and the state reasserts its control over his mind and body by destroying his soul.
This is par for the course in a lot of dystopian stories (1984 ended things in a much similar fashion). The difference here is that the revolution D-503 gets caught up in doesn't stop just because he's been lobotomized. In fact, it's still raging when the book comes to a close and we don't know whether it will eventually succeed or not. This is by design, and in fact has been foreshadowed in the book well before now. Early in the book, D-503 ponders the presence of irrationality in math:
I had to find a way of eating up, of crushing down, that square root of minus one. (8.13).
But later on, that becomes a spring into the infinite nature of the universe, "since the number of numbers is infinite, how can there be a last one?" (30.14)
Following that logic means that the ending needs to be unresolved. The universe is infinite and therefore there can be no real ending. Because hey, what happens after that? Zamyatin keeps the finale open-ended in acknowledgement of that fact, and by extension, of the possibilities that infinity infers (and which the State wants to wipe out).