I have an Arduino UNO, and use the serial for debugging purposes. What happens if I run the arduino on batteries and try to write to serial? Will the code stop running until a serial connection is availible?
No, that will not cause any problem.
What might hurt you is the fact that if you want to leave your Arduino in low power mode, but keep the serial potr disconnected and the serial port is a wakeup source, it might pick up sporadic (but frequent enough to cause be noticeable) noise that will trigger wakeups and spam with meaningless data your RX.
This, however, is not specific to the serial port, but it can happen to any wake up source that is enabled and left dangling.