Tried with daemon thread and signal handlers.