add a flag to be able to close the session

this nees of another change in the client , will link,