Remove race condition in panel event handling