Engine freezes after building the game

When I go to build my game, the engine freezes and does not respond. When I open Task Manager to force close it, Unreal Engine does not show in the processes tab, but does appear minutes later. Then when I open the project again, I have to build the lighting again and the engine freezes yet again and this keeps on happening. If anyone knows why this is happening or knows a solution, please help. Thanks.