Fixed a race-condition bug observed when closing multiple windows

Change-Id: I94c25aa173dddbc7a2d458d9f801463ac88e79cd
Merge pull request #43 from rdumusc/movetofrontbugfix

Fixed a race-condition bug observed when closing multiple windows