This quotation comes in the final scene as Hamlet lies dying. The fuller context is
O, I die, Horatio;
The potent poison quite o'er-crows my spirit:
I cannot live to hear the news from England;
But I do prophesy the election lights
On Fortinbras: he has my dying voice;
So tell him, with the occurrents, more and less,
Which have solicited. The rest is silence. (5.2.345-6).
Having, therefore, proclaimed that he is dying, Hamlet identifies his nomination for the new king: Fortinbras. Finally, Hamlet dies. The phrase "the rest is silence" signifies the death into which he will sink. It is perhaps ironic: after all, the play has explored the very vocal ghost of Hamlet's father who exhorts his son to "remember me". The phrase is also very nihilistic: there is no sense of an afterlife in it; no sense of heaven or hell. This is perhaps odd considering that he had failed to kill Claudius at his prayers for fear of sending him to heaven. Obviously, the "silence" referred to, which, whilst nihilistic, is also a very peaceful image, may be a peace that will descend on Denmark now that Claudius is dead. This would be consistent with the previous concern with the election of the new king. It is hard, however, to avoid the assumption that he is referring to his own death.