added proper signal handling for email service