Adds logging to heart component and signal handler for improved debugging. Changes signal handler to set a "StopPending" state to allow the main loop to handle shutdown. Fixes a potential thread join issue during shutdown.