Fix #28—Avoid rare app lock-up caused by race condition