BZ-1108472: general cleanup in order to have a clean shutdown on TOMCAT