How to re enable ControlAction NUI

Hi, i’m working on an NUI menu, i wan’t it to re enable the controls when it closed. Here is the thread that disable actions:

Citizen.CreateThread(function()
    TriggerServerEvent('isFirstConnect')
    while display do
        Citizen.Wait(0)
        DisableControlAction(0, 1, display) -- LookLeftRight
        DisableControlAction(0, 2, display) -- LookUpDown
        DisableControlAction(0, 142, display) -- MeleeAttackAlternate
        DisableControlAction(0, 18, display) -- Enter
        DisableControlAction(0, 322, display) -- ESC
        DisableControlAction(0, 106, display) -- VehicleMouseControlOverride
    end
end)

So the keys are disabled when the NUI is open but doesn’t enable on NUI close.
Any idea?

You need to set the ‘display’ value back to false after closing the NUI page.
Sent a call to your .lua script and register it in your client script, for example:

RegisterNUICallback("exit", function(data)
    display = false
end)