There's a decrementAndGet() method which you can store the result of and then check below.

Also, it's technically possible that multiple threads call decrement at the same time, the way this is written, you could decrement twice, then have both of those threads see -1 and try to close.  If you set it to decrementAndGet and set the equality on the if statement below to look for -1, then you will be guaranteed that it will only run once.