Fix reopening overlay

Without this change the overlay is going to be opened immediately after clicking on the close button of the overlay. So at the moment it is not possible to close the overlay. 

This PR fixes this problem.