Fix race condition in the synchronous command implementation