Re-factors session shutdown;

Signed-off-by: ashwinh <ashwinh@cybage.com>