The validity of the cart is managed by two cookies, woocommerce_cart_hash and woocommerce_items_in_cart. If you look at these cookies, they are set to expire “When the browsing session ends”. However, browsers do their own thing, so the answer to how long items remain in the cart depends on what browser the customer is using and the settings in that browser. For instance, if the browser is using a setting like “on start up, continue where I left off”, then cookies would not in fact be deleted at the end of the browsing session.
My own experience is that I’ve come back after a few days and there is still old stuff in my cart.
Cookies are set in class-wc-cart-session.php line 243. There is no filter that I can see, so its not possible to alter the function without altering this core file, and that would make updating tiresome.
There are filters that a developer can use to examine the cart at the moment of order. Its possible to use those filters to consider if the items are still valid and react accordingly.
For example a developer can use the action “woocommerce_checkout_order_review” to check the order, and if no longer valid, show a message and remove payment options.