Prevent end from being executed multiple times