I'm not a programmer nor a modder but when I look on the debug file there are some entries that seems to happen before the mouse "unclicking" and those are:
PCL: Checking for sunk ships...
Number of sunken ships found=0
Number of sunken ships last found=0
Don't know if it has something to do with it. The mouse problem does not happen only when ships are damaged.. It happens at random and always at the beginning.