Fix error case where cpl would try to unlock a file descriptor that was never locked