You'll need to give some more information in order to get some help. Try answering these questions:
1. At what point during the export process does FCPX close? In other words, does it begin to export at all?
2. Are you on the latest version of FCPX?
3. What version of Mac OS X are you running?
4. What are the project details? (frame rate, frame size, codecs of the footage)?
5. What are the specs of your computer? (Ram, GPU, model, hard drive types)?
6. Is your media on an external drive or the system drive?
7. Have you successfully exported your timeline to YouTube in the past, or is this your first time trying?
Answering these should provide enough info to get some initial suggestions.