fixing graceful termination
stopping monitor thread
fixing restart issue