Long story short, for guest user:
- with default browser settings cart is lost when he closes the browser.
- with "Continue where you left off" set on, cart will last for "cart retaining period" days.
For guest user cart is identified by session id.
Joomla session depends on session cookie and "session lifetime" mentioned by nicolas.
After "session lifetime" period, session is considered expired and is deleted by PHP(session garbage collector) on next request with probability 1%(by default).
Session cookie should be deleted when user closes browser, but this is ignored by most browsers when "Continue where you left off(Chrome)/Show my windows from last time(Firefox)" is set.
If there is no session but session cookie exists, Joomla will reuse session id from cookie.