Fix catch in atomic function.

Reset the atomic flag to its proper value after the catch.