By this point in Shakespeare's Hamlet, Claudius is becoming increasingly concerned about Hamlet's erratic behavior and with good reason. Hamlet never liked Claudius. Compared to his father, Claudius was "Hyperion to a satyr" and "no more like my father Than I to Hercules" (1.2.143, 155–156). Claudius married Hamlet's mother far too soon after Hamlet's father's death, and Hamlet has shown his displeasure with Claudius for that:
CLAUDIUS: . . . But now, my cousin Hamlet, and my son,—
HAMLET: A little more than kin, and less than kind!
CLAUDIUS: How is it that the clouds still hang on you?
HAMLET: Not so, my lord: I am too much i' the sun. (1.2.64–69)
Then Hamlet starts acting a little crazy. Claudius isn't sure if it's all an act, but he needs to be careful, so he tells Rosencrantz and Guildenstern to spy on Hamlet:
CLAUDIUS: Something have you heard
Of Hamlet's transformation
. . . What it should be,
More than his father's death, that thus hath put him
So much from the understanding of himself,
I cannot dream of. I entreat you both
. . . to gather
So much as from occasion you may glean,
Whether aught to us unknown afflicts him thus
That open'd lies within our remedy. (2.2.4, 7–10, 15–18)
There's also the business with Hamlet and Ophelia, some of which Claudius observed for himself—including the "To be, or not to be" speech (3.1.63–98)—followed by the "Get thee to a nunnery" scene (3.1.130–158). Claudius still isn't convinced Hamlet is really, truly mad, but he's decides that he must be vigilant:
CLAUDIUS: . . . Madness in great ones must not unwatch'd go. (3.1.198)
Now comes the play-within-a-play, The Murder of Gonzago, that Hamlet arranges to be presented; through this performance, Hamlet basically accuses Claudius of the murder of his father. Claudius knows that he overreacted and gave himself away. Now Hamlet knows for sure that Claudius killed his own brother. However, Claudius has no idea that, if it weren't for Hamlet's indecision in act 3, scene 3, he'd be dead now. Claudius stays alive until the end of the play.
At the beginning of act 4, scene 1, Gertrude comes to Claudius and tells him that Hamlet just killed Polonius, who was secretly listening to Hamlet's conversation with her. Until now, Claudius has been thinking about Hamlet's behavior in the abstract, but this incident with Polonius brings the situation into sharp focus: Hamlet is capable of killing people. Claudius's first thought and concern is that the man behind the curtain could have been him:
CLAUDIUS: . . . It had been so with us, had we been there. (4.1.14)
Claudius very quickly decides what needs to be done:
CLAUDIUS: O Gertrude, come away!
The sun no sooner shall the mountains touch
But we will ship him hence (4.1.29-31)
Claudius isn't taking any chances. The next time we see Hamlet and Claudius together (in act 4, scene 3), Hamlet has armed guards, and, soon after that, he's on a ship to England to have his head cut off.