Fixing issue where right click outside of target element doesn't close the menu