what I suggested is more for tests purpose where you know how long will it take to complete the process.
As you noticed it does not happen in console because console keep the session (and the java process) active as long as the application is active. So when dispose session is completely up to you and your requirements.
HTH