Finally fixed the x-button issue