How to switch pin between GPIO and UART?

Is there a way to switch pin PB1 between GPIO and UART? Once used for UART, GPIO will not work anymore:

#include <SoftwareSerial.h>

#define TXpin   PB1 
#define RXpin   PB2
SoftwareSerial mySerial(RXpin, TXpin);

void blink() {
    for(int i = 0; i < 10; i++) {
        digitalWrite(TXpin, HIGH);
        delay(500);
        digitalWrite(TXpin, LOW);
        delay(500);
    }
}

void setup() {
    pinMode(TXpin, OUTPUT);
    blink();  // This works!
    mySerial.begin(250000, 8, PARITY_NONE, 2);
    mySerial.println("Hello world");
    mySerial.end();
    pinMode(TXpin, OUTPUT);
    blink();  // No output anymore!
}