close database when leaving game