I have never been logged out while I was AFK... Oo
For online play it depends how the server is set up. Some have it set up if a player is inactive for x amount of time it kicks the player from the server. People make this to help with that. I.E. you had to do a chore and were going to be 10 minutes it saves the player the trouble of having to relog.