added shutdownHook to ensure sending a close event

+ isolated unit test from external '-Dshakuntala=on/off'

Change-Id: I83de4348e92222ccbc41ead2d3701d61f9876809