close database connection on gui closing