Disconnect from database when when appropriated