Fix lock/unlock pairing

Prevent IllegalMonitorStateException in case stmtHandle is null