Added catching of ^c and flushing of server communication so that server doesn't die