close database if no shared connection