On the 4th Of July 1902, Swamiji told his disciples in Belur Math that he was going to his room and that he was not to be disturbed. He closed the room and left his mortal body. He attained Mahasamadhi. According to some books, published by Ramkrishna Mission, his last thought was to surrender to the Mother after completing his work on Earth.
Also, Swamiji himself predicted that he would not live beyond 40. He left this earth at 39. He made some more predictions which came to be true.