Looking at your code, I could not find any "Close connection". You should handle the close connection, on both the VI side, and the device side. LabVIEW connection usually closes its own connections when the VI terminates but this is not a good practice. On the device side, if the connection is still open, you will run into errors.
The OS might also prevent to reuse some port values within a certain delay, especially when the open/close are not properly handled.