commit changes to db before closing

It worked before, but the docs suggest that was just luck.