Serial off blip


I'm running a simple sketch that triggers a device via digital pin 12 when it receives a serial command. All works fine but I've noticed that when you stop the serial connection with Arduino it triggers all the digital pins, which in turn triggers my device.

Is it possible to stop this, I only want to trigger the device when I receive serial communication and not when the serial connection is made.

Many thanks