fix memory leak

fix memory leak, when object, that represents
database in javascript, is deleted by GC (because of leaving
scope or by any other reason).