The Lord spoke to me after Nebuzaradan, the commanding officer, had set me free at Ramah. I had been taken there in chains, along with all the other people from Jerusalem and Judah who were being taken away as prisoners to Babylonia.
The commanding officer took me aside and said, "The Lord your God threatened this land with destruction,
and now he has done what he said he would. All this happened because your people sinned against the Lord and disobeyed him.
Now, I am taking the chains off your wrists and setting you free. If you want to go to Babylonia with me, you may do so, and I will take care of you. But if you don't want to go, you don't have to. You have the whole country to choose from, and you may go wherever you wish."
When I did not answer, Nebuzaradan said, "Go back to Gedaliah, the son of Ahikam and grandson of Shaphan, whom the king of Babylonia has made governor of the towns of Judah. You may stay with him and live among the people, or you may go anywhere you think you should." Then he gave me a present and some food to take with me, and let me go on my way.
References for Jeremiah 40:5
I went to stay with Gedaliah in Mizpah and lived among the people who were left in the land.