Fail and flush pending commands when closing a remote session