close button reimplementation