Detect SIGTERM in order to close the connection when shutting down

I modified the detection of interrupts so freesmdr can close the socket after receving a SIGTERM, it should make the termination of  freesmdr process cleaner.