To automatically close the context menu after a set time interval, you can use a Timer and send a ESC key stroke after the desired time interval as shown: