Check for running before closing