Don't use signal-unsafe longjmp in signal handler

This uses the method suggested by Leandro in
https://github.com/lpereira/lwan/issues/58 to close the main socket in
the signal handler and check for EBADF to break out of the main loop.

Fixes #58