fixing race condition on import shutdown