The session finishes when the browser closes (default setting, but can be changed), but the session data is not destroyed until the garbage collection routine is called.
If you want to use the method I suggested above you will need to write a custom session_handler.
I suggest you have a read through the section of the manual relating to custom session_handlers.