Fix releasing ressources on shutdown

JAVA-89 #fixes