Flew into Serbia and will leave via train; how will they know I left in case I want to return, legally, in the future?

I can stay 90 days in a 180 span. I will leave via train before staying 90 days. If I want to come back, say, 4 months later, how will they know I ever left?

I want to make sure I follow all of the laws. This is new to me and I don't know if not having an exit stamp in my passport will matter.

Another way to phrase this is: I'm an American traveling around Europe via train. I want things to stay legal and easy for me. Please advise! 😊