Null-terminates str properly now
Closes the X display