added a check to avoid work after shutdown