Trying to fix database close connection