Fix querywindow memory leak of connection/transaction