Only close db connection when disconnecting, keep the connection object

@icewind1991 @DeepDiver1975 @VicDeo @butonic