# Catching/Blocking Alt+f4 in Packaged Game

**URL:** <https://forums.unrealengine.com/t/catching-blocking-alt-f4-in-packaged-game/348273>\
**Category:** Multiplayer & Networking\
**Tags:** unreal-engine, UE4, question, CPP\
**Created:** [February 22, 2016, 2:52pm UTC](https://forums.unrealengine.com/t/catching-blocking-alt-f4-in-packaged-game/348273 "2016-02-22T14:52:57Z")\
**Posts on this page:** 1\
**Showing post:** 5

<div class="post-metadata">

**Author:** ![anonymous\_user\_4b24d331](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@anonymous\_user\_4b24d331](https://forums.unrealengine.com/u/anonymous_user_4b24d331)\
**Post date:** [October 11, 2017, 2:53pm UTC](https://forums.unrealengine.com/t/catching-blocking-alt-f4-in-packaged-game/348273/5 "2017-10-11T14:53:41Z")

</div>

Actually you can also handle window close requests in user code, without ever touching the engine source.

The viewport client does have a delegate for exactly that purpose, which can be obtained by the `UGameViewportClient::OnWindowCloseRequested()` accessor.

The world viewport client can be obtained with the `UGameInstance::GetGameViewportClient()` method, but beware that this is only available _after_ the GameInstance has been initialized, but not yet in the `UGameInstance::Init()` method.

So, as code example which will call delegateToCall if someone tries to close the window:

```
UGameInstance* instance = GetGameInstance();
if(instance)
{
	UGameViewportClient* viewPortClient = instance->GetGameViewportClient();
	if(viewPortClient)
	{
		viewPortClient->OnWindowCloseRequested().Bind(delegateToCall);
	}
}

```

If delegateToCall returns true, the window will be closed afterwards, if delegateToCall returns false, the close request will be ignored.

---

_[View the full topic](https://forums.unrealengine.com/t/catching-blocking-alt-f4-in-packaged-game/348273)._
