# Event on Close

**URL:** <https://forums.unrealengine.com/t/event-on-close/298087>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine\
**Created:** [November 4, 2014, 4:13am UTC](https://forums.unrealengine.com/t/event-on-close/298087 "2014-11-04T04:13:29Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![anonymous\_user\_957a4452](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_957a4452](https://forums.unrealengine.com/u/anonymous_user_957a4452)\
**Post date:** [November 5, 2014, 12:48pm UTC](https://forums.unrealengine.com/t/event-on-close/298087/2 "2014-11-05T12:48:05Z")

</div>

Hi Aaron,

I think the best way to do this. It is create custom game engine class and implement events you want.

You should add to DefaultEngine.ini

```
[/Script/Engine.Engine]
GameEngine=/Script/QAGame.MyCustomGameEngine

```

MyCustomGameEngine.h

```
#pragma once

#include "Engine/GameEngine.h"
#include "MyCustomGameEngine.generated.h"

UCLASS()
class UMyCustomGameEngine : public UGameEngine
{
	GENERATED_UCLASS_BODY()

	// When engine starts
	void Init(class IEngineLoop* InEngineLoop);
	// Close engine
	void PreExit();
};

```

MyCustomGameEngine.cpp

```
#include "QAGame.h"
#include "MyCustomGameEngine.h"

UMyCustomGameEngine::UMyCustomGameEngine(const FPostConstructInitializeProperties& PCIP)
: Super(PCIP)
{}

void UMyCustomGameEngine::Init(class IEngineLoop* InEngineLoop)
{
	Super::Init(InEngineLoop);
}

void UMyCustomGameEngine::PreExit()
{
	Super::PreExit();
}

```

Best regards,

---

_[View the full topic](https://forums.unrealengine.com/t/event-on-close/298087)._
