Fix auto closing bug