Add close function to menubar entry