Fixed crash when the last production building was killed while the mouse was still hovering over the build palette

#4137