At the end, Lennie is shot by George. This is because Lennie has caused trouble and George knows it's the only way to protect him from a more cruel punishment.
It could be due to his mental state and the stress of the events. Lennie's mind was already fragile, and the culmination of everything might have pushed him over the edge, causing hallucinations.
Lennie's character transformation in the novel is quite notable. At first, he's just a simple-minded guy with good intentions. However, events lead him to make mistakes that have tragic outcomes, showing a darker side to his nature.