Dealing with custom states in cleanup method