fixing shutdown synchronization issue