ESP8266 NodeMCU Can't upload program when SPI device connected

When trying to upload a program I get the error below if the SPI device is connected. If I disconnect the device the program will upload just fine.

serial.serialutil.SerialException: could not open port 'COM7': PermissionError(13, 'Access is denied.', None, 5)

The SPI device is connected to the pins below:

D5 - CLK
D6 - MOSI
D7 - MISO
D8 - CS

I disabled and reenabled the COM Port on my PC and it seems to have fixed the problem. The problem has reoccurred a couple times but repeating the disable/enable of the port again fixes it.