Fixed 2 crash bugs and a memory leak in src/JSDatabase.cpp and added db.close()