Cleanup all monitoring resources before overwriting monitor with a new
instance.
Fix potential nullpointer