Add comments about calling close().
Make port lock fair to prevent starvation; make sure the handling of
releasing the lock is more robust to exceptions.
Tweak error message for better readability.