Most likely, whilst Saul and his men were being constrained by the Spirit (1 Samuel 19:18–24), David left Ramah and returned to Gibeah. He may have been back in the town for quite some time, long enough to allow things to settle down and for Saul to focus his attention elsewhere.1
1 Then David fled from Naioth in Ramah and came and said before Jonathan, “What have I done? What is my guilt? And what is my sin before your father, that he seeks my life?”