Refactor signal handling; add graceful shutdown timeout; cleanup exit() codes.